On Wed, Aug 8, 2018 at 12:28 PM Paul Moore <p.f.mo...@gmail.com> wrote:
>
> On Wed, 8 Aug 2018 at 16:58, Oscar Benjamin <oscar.j.benja...@gmail.com> 
> wrote:
> > Thinking about this some more: closing() can ensure finalisation but
> > it is still generally bad to yield from a with block. Some context
> > managers are designed to temporarily alter global state between
> > __enter__ and __exit__ - this can be very confusing if you use them
> > around a yield block.
>
> Surely that's *precisely* what PEP 567 (Context Variables) was
> designed to address?

To be even more precise, PEP 550 was designed to solve state handling
problem for both "await" (coroutines) and "yield" (generators). It was
rejected in favour of a more simplistic PEP 567 that solves it only
for coroutines.

PEP 568 was later drafted by Nathaniel. It applies PEP 550's ideas to
567 API/design to allow generators to have execution context too in
Python 3.8 or 3.9. The fate of PEP 568 is still undecided.

Yury
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to