On Fri, Apr 27, 2018 at 1:38 AM, Gustavo Carneiro firstname.lastname@example.org wrote: > >
On 26 April 2018 at 16:18, Chris Angelico email@example.com wrote: >
On Thu, Apr 26, 2018 at 11:13 PM, Martin Teichmann
when reading PEP 572 I actually liked it a lot - I think it's actually a cool idea. I think it's actually that cool an idea that it should be made the default way of doing an assignment, over time phasing out the good ole =.
This would have several benefits:
in this case, for sure, we should make it possible to chain :=s, for example by making it bind right-to-left, so that a := b := 3 would be a := (b := 3)
I'm sorry if somebody brought that up already, but the discussion has grown so huge that I couldn't read through it entirely.
It has indeed grown huge. And in the interests of not growing it even huger, I'm not going to rehash the arguments against making := into the one and only operator, save to say one thing: there's no way that "x = 1" can be removed from the language any time soon, and by "soon" I mean even by the Yes Prime Minister definition, where "any day now", in strategic terms, meant "within the next half century".
In the interest of that, do you think := can be made illegal, by the grammar, if used outside an expression?
a = 1 # legal a := 1 # Syntax error if a := 1: # legal
No. Any expression may be used as a statement, so this isn't "outside an expression".