Hacker News new | ask | show | jobs
by outerspace 2528 days ago
Does it make sense to use := everywhere (can it be used everywhere?) instead of just in conditionals? Just like Pascal.
2 comments

About 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
It'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.