Message307155
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. |
|
Date |
User |
Action |
Args |
2017-11-28 19:39:46 | jaraco | set | recipients:
+ jaraco |
2017-11-28 19:39:46 | jaraco | set | messageid: <1511897986.14.0.213398074469.issue32158@psf.upfronthosting.co.za> |
2017-11-28 19:39:46 | jaraco | link | issue32158 messages |
2017-11-28 19:39:46 | jaraco | create | |
|