Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PEP 8: Function and method arguments naming convention

From PEP 8 section of Function and method arguments :

Always use self for the first argument to instance methods.

Always use cls for the first argument to class methods.

If a function argument's name clashes with a reserved keyword, it is generally better to append a >single trailing underscore rather than use an abbreviation or spelling corruption. Thus class_ is >better than clss. (Perhaps better is to avoid such clashes by using a synonym.)

It does not say anything about the preferred naming style. I guess it should be "lower_case_with_underscores" or "mixedCase" but I am not sure. What is preferred?

like image 228
iddober Avatar asked Nov 13 '22 04:11

iddober


1 Answers

From the PEP 8 section immediately above the one you quoted.

Function Names

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

mixedCase is allowed only in contexts where that's already the prevailing style (e.g. threading.py), to retain backwards compatibility.

Link: https://www.python.org/dev/peps/pep-0008/#function-names

like image 144
ThatGuyRob Avatar answered Nov 14 '22 22:11

ThatGuyRob