[issue10049] Add a "no-op" (null) context manager to contextlib

Nick Coghlan report at bugs.python.org
Fri Oct 8 14:09:43 CEST 2010


Nick Coghlan <ncoghlan at gmail.com> added the comment:

Actually, the singleton idea isn't a bad one, but I'd go one step further and skip the factory function as well. So change that to be:

class NullContext():
   ... # as per nullcontext in my last message

nullcontext = NullContext()

(with the example in the docstring adjusted accordingly)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10049>
_______________________________________


More information about the Python-bugs-list mailing list