New submission from Jason R. Coombs <jar...@jaraco.com>: The contextlib docs explain why a decorator is nice:
> It makes it clear that the cm applies to the whole function, rather than just > a piece of it (and saving an indentation level is nice, too). However, the built-in context managers that could readily supply this interface don't derive from DecoratorContext. In jaraco.context, I [added decorator support by simply deriving from the two base classes](https://github.com/jaraco/jaraco.context/commit/5aa7b0bb222cff5009a2f0dc3ea49db9e7a6b71a#diff-efbedfbbcb7f61268cfeff04a32fa59d). But it got me thinking - couldn't suppress (and possibly other) contextlib decorators support this usage out of the box? If there's interest, I'll put together a patch with test. ---------- components: Library (Lib) messages: 307155 nosy: jason.coombs priority: normal severity: normal status: open title: Suppress (and other contextlib context managers) should work as decorators (where appropriate) versions: Python 3.7 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue32158> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com