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

后端 未结 13 2291
生来不讨喜
生来不讨喜 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:23

    As mentioned, PEP 8 says to use lower_case_with_underscores for variables, methods and functions.

    I prefer using lower_case_with_underscores for variables and mixedCase for methods and functions makes the code more explicit and readable. Thus following the Zen of Python's "explicit is better than implicit" and "Readability counts"

提交回复
热议问题