Raymond Hettinger <raymond.hettin...@gmail.com> added the comment: > But it got me thinking - couldn't suppress (and possibly other) > contextlib decorators support this usage out of the box?
They possibly could but probably shouldn't. My experience is that giving them a dual role makes them more complicated and harder to understand. For suppress() in particular, wrapping a whole function is likely an anti-pattern. Usually we advise people to put as little as possible in the try-block to avoid catching unexpected exceptions. Also, I think it would be inevitable that people would try to apply these to generators or awaitables and find that they don't mix well. ---------- nosy: +rhettinger _______________________________________ 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