Re: [Python-Dev] Examples for PEP 572

2018年7月06日 08:06:56 -0700

On 2018年07月04日 00:25, Nathaniel Smith wrote:
The only cases that seem potentially valuable to me are the ones that
are literally the form 'if <name> := <expr>` and 'while <name> :=
<expr>'. (I suspect these are the only cases that I would allow in
code that I maintain.) The PEP does briefly discuss the alternative
proposal of restricting to just these two cases, but rejects it
because it would rule out code like 'if (<name> := <expr>)
<comparison> <expr>'. But those are exactly the cases that I want to
rule out, so that seems like a plus to me :-).
The 'if <expr> as <name>' syntax would be a simple way to encode
exactly these simple non-harmful cases. The PEP rejects it on the
grounds that 'as' is already used in a different way by 'except' and
'with'. But... 'as' is *also* used in the *same* way by 'import', so
the argument feels disingenuous. Yeah, there'd be an inconsistency,
but that inconsistency already exists, and adding 'if ... as' and
'while ... as' wouldn't create any *new* inconsistencies.
Agreed, tried to make this point in several threads.
-Mike
_______________________________________________
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to