Suggested python feature: allowing except in context maneger

Albert-Jan Roskam sjeik_appie at hotmail.com
Sun Jun 16 17:41:52 EDT 2024


     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


More information about the Python-list mailing list