I mentioned this off-hand in the other thread, but the more I think about it 
the more I think it is a reasonable compromise between the two schools of 
thought on PEP 533.


Wouldn't the new PEG parser allow a "closed for" statement without breaking 
code that uses "closed" as a variable (it would be a context sensitive keyword)?


The users who work in the space that cares about such things can start writing:

closed for document in read_newline_separated_json(path):
    ...

Instead of:

with closing(read_newline_separated_json(path)) as genobj:
    for document in genobj:
        ...

It is still on the API consumer to know when they need to use a "closed for" 
loop, but at least they don't have to restructure their code, and there would 
be no backwards incompatibility.


If we want to get really crazy we can also allow an "open for" loop and kick 
off a very long deprecation process where eventually an unadorned for loop 
would become "closed" by default.


Thanks,

Brendan
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/MZIVRIM5JLS5YOAEVBIJFHVROZ3AJRI5/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to