https://docs.python.org/3/library/contextlib.html I've got it set to English, 3.12.3. The "up" after "cleanup" should be deleted. ExitStack<https://docs.python.org/3/library/contextlib.html#contextlib.ExitStack> makes it possible to instead register a callback for execution at the end of a with statement, and then later decide to skip executing that callback: from contextlib import ExitStack with ExitStack() as stack: stack.callback(cleanup_resources) result = perform_operation() if result: stack.pop_all() This allows the intended cleanup up behaviour to be made explicit up front, rather than requiring a separate flag variable. Michael L. Kass | Leidos Sr Software Developer Transportation Solutions (ERAM Software) michael.kass@leidos.com<mailto:michael.kass@leidos.com> | www.leidos.com +1 (301) 240-5734 O
On Fri, May 31, 2024 at 10:52 AM Kass, Michael [US-US] via docs <docs@python.org> wrote:
https://docs.python.org/3/library/contextlib.html
I’ve got it set to English, 3.12.3. The “up” after “cleanup” should be deleted.
Thanks for the report! This has been fixed in https://github.com/python/cpython/pull/119867, with backports to 3.12 and 3.13. -- Zach
participants (2)
-
Kass, Michael [US-US]
-
Zachary Ware