[Python-ideas] If branch merging

Ethan Furman ethan at stoneleaf.us
Thu Jun 11 21:10:11 CEST 2015

On 06/11/2015 03:56 AM, Chris Angelico wrote:

> while input("Spam? ") as spam:
>      print(globals())
>      break
> Spam? yes
> {... 'spam.0x7f2080260228': 'yes'...}

Having names not leak from listcomps and genexps is a good thing.

Having names not leak from try/execpt blocks is a necessary thing.

Having names not leak from if/else or while is confusing and irritating: there is no scope there, and at least 'while' should be similar to 'for' which also does a name binding and does /not/ unset it 
at the end.

> Aside from being a fun exercise for me, building a Volkswagen
> Helicopter, is this at all useful to anybody?

I would find the 'as NAME' portion very useful as long as it wasn't shadowing nor unset.


More information about the Python-ideas mailing list