Nick Coghlan <[email protected]> added the comment:
The idea of building this into contextlib actually came out on off-list
discussion between Michael and I. To quote the original suggestion he sent to
me:
"""What do you think about adding ContextDecorator to contextlib for Python 3.2?
http://pypi.python.org/pypi/contextdecorator
It's a simple recipe but useful nonetheless (and Barry Warsaw at least is very
enthusiastic about it ;-).
ContextDecorator allows you to create APIs that behave as both context managers
and as decorators. It also provides the optional exception handling capability
of __exit__ for decorators. This isn't an uncommon pattern, used in libraries
like mock, py.test and django, and it is at least slightly fiddly to get
right."""
I agree it is good to have that additional motivation (and the reference to
previous work) here in the tracker issue rather than squirreled away in a
couple of private email archives.
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue9110>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com