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

Eric Fahlgren ericfahlgren at gmail.com
Fri Mar 2 15:04:34 EST 2018


On Fri, Mar 2, 2018 at 10:27 AM, Jelle Zijlstra <jelle.zijlstra at gmail.com>
wrote:

>
> I wonder if we could have a more limited change to the language that would
> allow only the as/while use cases. Specifically, that means we could do:
>
> while do_something() as x:
>     print(x)
>

​The "while" case is the only part of the PEP that has any traction with
me.  It doesn't add any keywords, scope can be identical to "with" and it
cleans up a code pattern that is very common.​

Every one of these comprehension examples has me scratching my head,
thinking back a couple hundred (thousand? :) ) posts to Barry's quip,
"Sometimes a for loop is just better" (or something along those lines).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180302/47848212/attachment.html>


More information about the Python-ideas mailing list