> ALGOL decided to stick close to mathematical tradition
And now we have all 3 in Python (=, ==, and :=) which makes me sad.
And now we have all 3 in Python (=, ==, and :=) which makes me sad.
if is_logged_in=True:
allow_access()
I've got... opinions on the way python separates statements and expressions, but there's some real benefits to it too. is_logged_in := True
or if is_logged_in := True:
I agree that this would require blurring the statement/expression distinction. You can still do that in a weird way, by disguising your assignment as an expression. This is valid: (is_logged_in := True)
The reason it was done that way because := was an afterthought, and making it the assignment operator would have introduced a breaking incompatibility. That lead to having 3 different symbols for 2 use cases (assignment and comparison).:= was bolted on after of course, and I think that was a mistake, but no one asked me, nor do I expect anyone to ;P