[issue3957] [contextlib] Reverse order of locking

David Naylor report at bugs.python.org
Wed Sep 24 17:03:26 CEST 2008


David Naylor <naylor.b.david at gmail.com> added the comment:

Apologies, obviously the invert function should be preceded by an 
@contextmanager to become:

@contextmanager
def invert(thing):
  thing.__exit__(None, None, None)
  yield thing
  thing.__enter__()

[Although there may be a better way of doing this, perhaps as a 
class?]

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


More information about the Python-bugs-list mailing list