Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why PyCharm does not allow uppercase letters in method naming?

Tags:

python

pycharm

I am comfortable with Java naming conventions where you are free to name your methods as long as it starts with lowercase so methodForTest() is acceptable.

However, Python (PyCharm IDE) complains for this way and it requires all lowercase.

Why? Can I disable this so I can use uppercase in method naming?

like image 730
Jack Hoff. Avatar asked Oct 12 '25 17:10

Jack Hoff.


1 Answers

Python has no such limitation.

Python identifiers must start with an underscore or letter (upper or lowercase), followed by any number of underscores, digits or letters (again, upper or lowercase, doesn't matter); this means an ALL_UPPERCASE name is perfectly valid Python. See the Identifiers and keywords section in the reference documentation; Python 3 expanded on this by allowing a wider range of Unicode.

However, the widely adopted PEP 8 Python styleguide does have this to say on naming functions:

Function names should be lowercase, with words separated by underscores as necessary to improve readability.

This is a convention however, not a syntactic requirement. Perhaps your IDE has a linter installed that warns when you break this convention. You can, if you so wish, ignore it. I note that PyCharm implements such a check, for example.

In PyCharm, you can click on the warning icon and tell PyCharm to ignore the class of errors:

PyCharm *Ignore errors like this* option

Also see the PyCharm documentation on suppressing inspections.