Suggested python feature: allowing except in context maneger
j
rtm443x at googlemail.com
Mon Jun 17 07:35:54 EDT 2024
On 2024-06-13 23:49, Cameron Simpson via Python-list wrote:
> On 13Jun2024 19:44, dieter.maurer at online.de <dieter.maurer at 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.
I agree. If python allowed statement lambdas you could write what you
want above within the language (albeit a bit clumsily). It's very handy.
jan
>
> Cheers,
> Cameron Simpson <cs at cskk.id.au>
More information about the Python-list
mailing list