[Python-ideas] with None (Was: Re: Enhanced context managers with ContextManagerExit and None)

Masklinn masklinn at masklinn.net
Tue Aug 13 17:29:38 CEST 2013


Furthermore:

On 2013-08-13, at 16:48 , Serhiy Storchaka wrote:
> 
> And when the with statement will support None as a "null-manager":

I think that is a terrible idea, and will be a source of woe and bugs
more than a solution to anything.

If you want an optional context manager, why not create an
OptionalContextManager(object | None) which delegates to the underlying
non-None CM? That's simple, that's clear, that's explicit, and that's
not a hack.


More information about the Python-ideas mailing list