[issue11647] function decorated with a context manager can only be invoked once

Michael Foord report at bugs.python.org
Sat Mar 26 01:15:22 CET 2011


Michael Foord <michael at voidspace.org.uk> added the comment:

I'm strongly with Antoine on this. If you use context manager as a decorator you should be able to reuse it - and in general both generators and context managers can be reused and so I don't understand the phrase 'moral equivalent of the implicit context manager'.

If having APIs that can be used as context managers *and* decorators is a useful thing (and usage in django, py.test and mock seems to show that it is) then this functionality should be provided.

----------

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


More information about the Python-bugs-list mailing list