[issue9110] contextlib.ContextDecorator

Raymond Hettinger report at bugs.python.org
Sat Jul 10 05:02:32 CEST 2010


Raymond Hettinger <rhettinger at users.sourceforge.net> added the comment:

I can shake the feeling that this is going to end-up being rarely used cruft that causes more confusion than its worth.  The use case and motivation isn't clear (why do context managers need to be both context managers and decorators)?

Has this decorator/contextmanager mix been used "in the wild" and shown any degree of popularity?  AFAICT, it doesn't seem to have come in newsgroup discussions, feature requests, utility modules, or a published recipe.  

Do we have any strong examples of code that is improved by the use of a decorating context manager?  

One issue for me is that my understanding of decorators (as function/classs wrappers) and of context managers (deeply associated with the with-statement) have no overlap.  ISTM, that code using both in the same object would be too clever by far, making it difficult to explain and difficult to debug.

Also, Jack's critiques seem valid to me -- too much machinery for too little benefit.

----------
nosy: +rhettinger

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


More information about the Python-bugs-list mailing list