On 01.05.2020 10:44, Ram Rachum wrote: > > > On Fri, May 1, 2020 at 11:37 AM M.-A. Lemburg <m...@egenix.com > <mailto:m...@egenix.com>> wrote: > > Hi Ram, > > I think you are confusing the exception type with the exception > reason. > > > Some time ago `ModuleNotFoundError` was added as a subclass of > `ImportError`, which I really liked. Was this also another instance of a > confusion between the exception type and the exception reason?
No, because the ImportError can actually mean a lot of things (the import machinery being rather complex) and you will want to be able to catch the error situation where the module is not installed, rather than e.g. an error which happened while loading an installed module. > 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. > > > Why would you have to memorize them? If you're writing an except clause, > you could still write `except ValueError:` and it'll work the same as > before. > > Do you feel that the addition of `ModuleNotFoundError` meant that you > now had to memorize a new exception? Sure, because I would not know that this is actually a subclass of ImportError. The hierarchy already has quite a few exeption types and it's not always clear that one type is subclass of another: https://docs.python.org/3/library/exceptions.html#exception-hierarchy -- 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/22PK2OB6QHMNJUAMKO4ERVISOIGSMKTK/ Code of Conduct: http://python.org/psf/codeofconduct/