[Python-ideas] PEP 572: Statement-Local Name Bindings

Paul Moore p.f.moore at gmail.com
Wed Feb 28 15:30:43 EST 2018


On 28 February 2018 at 20:16, Alex Walters <tritium-list at sdamon.com> wrote:
> For what its worth, I'm +1 on it.
>
> I actually like that it would allow:
>
> while (something() as var):
>     something_else(var)
>
> ...without being a bug magnet.  The bug magnet isn't the assignment of a
> name in the condition of a while loop, it's the fact that assignment is a
> simple typo away from comparison.  This is not a simple typo away from
> comparison (the operands are a different order, too).

For me, the problem isn't so much with the expected use cases (with
the ironic exception that I dislike it for the original motivating
example of list comprehensions), it's that any "unusual" use of the
construct seems to raise more questions about the semantics than it
answers.

I remain -1, I'm afraid.

Paul


More information about the Python-ideas mailing list