On 30 June 2018 at 09:49, Chris Barker - NOAA Federal via Python-Dev
On Jun 28, 2018, at 8:21 PM, Tim Peters
wrote: Seems it’s all been said, and Tim’s latest response made an excellent case for consistency.
But:
Regardless of how assignment expressions work in listcomps and genexps, this example (which uses neither) _will_ rebind the containing block's `x`:
[x := 1]
This reinforces my point that it’s not just about comprehensions, but rather that the local namespace can be altered anywhere an expression is used — which is everywhere.
That trivial example is unsurprising, but as soon as your line of code gets a bit longer, it could be far more hidden.
The significant semantic differences between "{x : 1}" and "{x := 1}" are also rather surprising :) Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia