Sujet : Re: Suggested python feature: allowing except in context maneger
De : sjeik_appie (at) *nospam* hotmail.com (Albert-Jan Roskam)
Groupes : comp.lang.pythonDate : 16. Jun 2024, 23:41:52
Autres entêtes
Message-ID : <mailman.141.1718574125.2909.python-list@python.org>
References : 1 2
The example exception is not what bothers me. The syntax change is
nowhere near as useful as `with` and context managers. They provide an
excellent idiom for resource usage and release.
Your suggestion complicates the `with` statement and brings only a tiny
indentation reduction over the `with`-inside-`try` idiom. It brings no
semantic changes or new features.
====
I also don't see the added value. If you desperately want to get rid of an
indentation level, you could use an except
hook.
https://docs.python.org/3/library/sys.html#sys.excepthook