Re:What's Coming in Python 3.8
by outerspace on Wednesday July 17, 2019 @07:18PM
(#20465015)
Does it make sense to use := everywhere (can it be used everywhere?) instead of just in conditionals? Just like Pascal.
[ Parent
| on HN ]
Re:What's Coming in Python 3.8
by DonHopkins on Wednesday July 17, 2019 @07:56PM
(#20465291)
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"
# ENDIt'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.