Sujet : Re: Suggested python feature: allowing except in context maneger
De : guruyaya (at) *nospam* gmail.com (Yair Eshel)
Groupes : comp.lang.pythonDate : 14. Jun 2024, 08:07:39
Autres entêtes
Message-ID : <mailman.135.1718345274.2909.python-list@python.org>
References : 1 2 3
Cameron, I'm not really sure I got your point. I've used the "file not
found" exception as an example for a behavior typical on context managers.
This could be a failure to connect to DB, or threads. It also applies to
any kind of possible exception, whether cased by the context manager itself
or the lines inside it. Long story short, this syntax change is as useful
as context managers are
On Fri, 14 Jun 2024, 01:49 Cameron Simpson, <
cs@cskk.id.au> wrote:
On 13Jun2024 19:44, dieter.maurer@online.de <dieter.maurer@online.de>
wrote:
Why not use:
```
try:
with open()...
...
except FileNotFoundError:
...
```
>
This is exactly what the OP was expressing dissatisfaction with.
>
I'm -1 on the idea myself - not every combination of things needs
additional syntactic support, and doing stuff like merging an `except`
with a `wtih` is bound to introduce some weird corner case, complicating
its semantics.
>
Cheers,
Cameron Simpson <cs@cskk.id.au>
>