I've been tripped up a couple of time by a few Exception names being lower case 
both in code and tracebacks.  In particular `error` (all lower case)
I tend to read `error` as a function instead of a class. 

According to my non-scientific grep-foo, I find that  ~ 300 descendant from 
Exceptions start with an upper case: 

~/dev/cpython[master ✗] $ rg '^[ ]*class [A-Z][a-zA-Z]+\(' | grep Excep | wc  -l
     333
18 of those are `Error` uppercase: 
~/dev/cpython[master ✗] $ rg '^[ ]*class Error\(' | wc -l
      18
but 4 are lower case: 

~/dev/cpython[master ✗]  $ rg '^[ ]*class [a-z][a-zA-Z]+\(' | grep Exception
Lib/sre_constants.py:class error(Exception):
Lib/imaplib.py:    class error(Exception): pass    # Logical errors - debug 
required
Doc/faq/design.rst:   class label(Exception): pass  # declare a label
Lib/dbm/__init__.py:class error(Exception):

... there are probably others if they don't directly inherit from Exception of 
course.

My question is in two part: 

1) For consistency would it make sens to try to capitalize – where possible – 
Exceptions names ? For example `error` to `Error` (keeping error as an alias 
for backward compatibility for now). 
2) If (1), would it be ok to actually give a better name to some of those 
exceptions ? e.g: Lib/sre_constants.py:class error to CompileError for example.

Thanks.
_______________________________________________
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/64NHNY6RD4HQWBSBV6J7XIN7UAHNTQBR/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to