Splitting = and := in python is very intentional though, It makes writing bugs like this impossible:
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.Splitting = and := is intentional, but not for the reason you stated. We could have used := for all assignments from the beginning:
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).except if := was the default then accidentally typing ":=" instead of "==" would be the easy bug to make.
:= 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
And now we have all 3 in Python (=, ==, and :=) which makes me sad.