On 01.05.2020 11:40, Peter Otten wrote:
> M.-A. Lemburg wrote:
> 
>> Hi Ram,
>>
>> I think you are confusing the exception type with the exception
>> reason. By adding 100 more exception types, you don't make things
>> easier, but instead you complicate things, since we'd all have
>> to memorize those 100 exception types.
>>
>> That said, enhancing the error reasons texts is certainly something
>> that would help everyone.
>>
>> Adding more exception types to the stack makes sense when there's
>> a dedicated need to catch only specific sub types, but even there
>> it's already possible to add this extra information to the exception
>> objects as e.g. .errno or similar attribute.
> 
> There is prior art, though, specifically for errno:
> 
> $ python2 -c 'open("not-there")'
> Traceback (most recent call last):
>   File "<string>", line 1, in <module>
> IOError: [Errno 2] No such file or directory: 'not-there'
> $ python3 -c 'open("not-there")'
> Traceback (most recent call last):
>   File "<string>", line 1, in <module>
> FileNotFoundError: [Errno 2] No such file or directory: 'not-there'

Yes, and the reason for having those is that you will want to
often catch those exceptions in applications in a platform independent
way. That doesn't apply to all OS errors, though.

As with all great new features, a case has to be made why an
addition is necessary, what the benefits and drawbacks are and
why we should force millions of Python programmers to learn about
the addition.

Note that we're talking about the Python core, not an application
or Python package from PyPI. Those can, of course, define their own
exceptions and hierarchies.

I assume Ram was testing waters here... just to get an idea of what
it takes for such a change to go in, please see the PEP for the
OS/IO exception hierarchy changes:

https://www.python.org/dev/peps/pep-3151/

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Experts (#1, May 01 2020)
>>> Python Projects, Coaching and Support ...    https://www.egenix.com/
>>> Python Product Development ...        https://consulting.egenix.com/
________________________________________________________________________

::: We implement business ideas - efficiently in both time and costs :::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611
               https://www.egenix.com/company/contact/
                     https://www.malemburg.com/
_______________________________________________
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/OYLCV4XDIMHRBCUQNCHCM3Z5YWJZTJCI/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to