What is the naming convention in Python for variable and function names?

后端 未结 13 2314
生来不讨喜
生来不讨喜 2020-11-22 08:50

Coming from a C# background the naming convention for variables and method names are usually either camelCase or PascalCase:



        
13条回答
  •  遇见更好的自我
    2020-11-22 09:28

    See Python PEP 8: Function and Variable Names:

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

    Variable names follow the same convention as function names.

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

提交回复
热议问题