[Python-ideas] Make "yield" inside a with statement a SyntaxError
Rhodri James
rhodri at kynesim.co.uk
Wed Aug 8 12:16:46 EDT 2018
On 08/08/18 16:55, Oscar Benjamin 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.
Yes, but those sorts of context managers need to be used with care in
all sorts of circumstances. Fiddling with global state is always fraught.
--
Rhodri James *-* Kynesim Ltd
More information about the Python-ideas
mailing list