5

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?

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

0

For function and method arguments, lowercase with underscore is conventional as shown below:

 # Here def display_first_name(first_name): print(first_name) 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.