5 ms·
Does it make sense to use := everywhere (can it be used everywhere?) instead of just in conditionals? Just like Pascal.
by outerspace 7y ago
Does it make sense to use := everywhere (can it be used everywhere?) instead of just in conditionals? Just like Pascal.
- DonHopkins 7y agoAbout as much sense as it makes to use ; after every Python statement. Just like Pascal. (Yeah I know, ; is a statement separator, not a statement terminator in Pascal.) As long as you're being just like Pascal, did you know Python supported Pascal-like "BEGIN" and "END" statements? You just have to prefix them with the "#" character (and indent the code inside them correctly, of course). ;) if x < 10: # BEGIN print "foo" # END
- ben509 7y agoIt's not valid in an assignment statement, so you can't use it everywhere. FWIW, I agree with the sentiment; I use := for assignment in my language precisely because that's the correct symbol. But even there, my grammar accepts = as assignment as well because I type it from habit.