On 2024-06-13 23:49, Cameron Simpson via Python-list wrote:
On 13Jun2024 19:44, dieter.mau...@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 eve
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 red
On 14Jun2024 09:07, Yair Eshel wrote:
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
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 t
On 13Jun2024 19:44, dieter.mau...@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,
Yair Eshel wrote at 2024-6-13 13:01 +0300:
> ...
>I would like to suggest an alternative syntax, that will, in a sense, apply
>the best of both worlds:
>
>import logging
>with open('sample_data/README.md') as f:
> print (len(f.read()))
>except FileNotFoundError:
> logging.error("File not")
Are y
> On 13 Jun 2024, at 11:01, Yair Eshel via Python-list
> wrote:
>
> I read this is a good place to give some suggestions for features in
> python.
Best place these days is to raise an idea on https://discuss.python.org/
Beware that this idea has come up in the past and was rejected.
Barry
Hello. I read this is a good place to give some suggestions for features in
python. If not, please let me know.
This is an example of a code I normally use in my everyday work:
import logging
try:
with open('sample_data/READM.md') as f:
print (len(f.read()))
except FileNotFoundError:
loggi