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