Yes https://docs.python.org/3/library/contextlib.html#contextlib.ContextDecorator

On Thu, Mar 19, 2020 at 3:26 PM Stephen J. Turnbull <turnbull.stephen.fw@u.tsukuba.ac.jp> wrote:
Andrew Barnert via Python-ideas writes:

 > [A] context manager seems perfect. It allows you to hint any
 > statement, including a loop statement, by adding whatever code you
 > want that gets run before and after the statement.

I wonder: The analogy "decorator : function :: with : suite" seems
useful here.  Is it useful in general?

Steve
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-leave@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/BOV5WZYTYUR4EFYCM2Q2PER5QOUUWOAC/
Code of Conduct: http://python.org/psf/codeofconduct/