[Python-ideas] PEP 572: Statement-Local Name Bindings, take three!
Rhodri James
rhodri at kynesim.co.uk
Mon Mar 26 10:33:52 EDT 2018
On 26/03/18 02:24, Guido van Rossum wrote:
> I gotta say I'm warming up to := in preference over 'as',*if* we're going
> to do this at all (not a foregone conclusion at all).
I have the usual objection to glyphs (hard to look up or get help on),
but ":=" raises two issues all of its own.
* On the plus side, it looks like some kind of assignment. People
reading through the code will not be overly surprised to find it results
in a name binding.
* On the minus side, it doesn't quite look like an assignment statement.
While my crystal ball is cloudy, I can well imagine beginners becoming
very confused over which symbol to use in which circumstance, and a lot
of swearing when:
x := f()
if (y = g(x)) is not None:
h(y)
results in syntax errors.
I'm inclined to think you want assignment expressions to look unlike
assignment statements to avoid this sort of confusion.
--
Rhodri James *-* Kynesim Ltd
More information about the Python-ideas
mailing list