On Sun, Oct 11, 2020 at 6:48 PM David Mertz <me...@gnosis.cx> wrote:

> I'm not advocating for it (nor against it). But the OP proposes something
> clear different from the example in current Python.
>
> On Sun, Oct 11, 2020, 12:39 PM Wes Turner
>
>> try:
>>     f = open('myfile.txt')
>>     s = f.readline()
>>     i = int(s.strip())
>> except OSError as err:
>>     print("OS error: {0}".format(err))
>> except ValueError:
>>     print("Could not convert data to an integer.")
>> except:
>>     print("Unexpected error:", sys.exc_info()[0])
>>     raise
>> ```
>>
>
> I.e.
>
> try:
>     might_raise_OSError()
> except OSError as err try:
>     might_raise_ValueError()
> except ValueError try:
>     might_raise_other()
> except:
>     oh_well()
>
> The proposal is to more concisely catch exceptions raised within the
> 'except' suites themselves.
>

But I think Wes has shown pretty clear evidence that the proposal is easily
misinterpreted. It looks too similar to existing syntax. Something that's
more visually distinct at a glance is required.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/QPU3DOWW7AVDZP4GSUUBQQMS4FTLJBUS/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to