yangsuiyun / master-python

Python修炼大法
0 stars 0 forks source link

Python Name notation #2

Open yangsuiyun opened 4 years ago

yangsuiyun commented 4 years ago

module_name, package_name, ClassName, method_name, ExceptionName, function_name, GLOBAL_CONSTANT_NAME, global_var_name, instance_var_name, function_parameter_name, local_var_name

yangsuiyun commented 4 years ago

1、_xxx 不能用于’from module import *’ 以单下划线开头的表示的是protected类型的变量。

即保护类型只能允许其本身与子类进行访问。

2、__xxx 双下划线的表示的是私有类型的变量。只能是允许这个类本身进行访问了。连子类也

不可以

3、__xxx_ 定义的是特列方法。像init__之类的

yangsuiyun commented 4 years ago
code sample message
N801 class names should use CapWords convention
N802 function name should be lowercase
N803 argument name should be lowercase
N804 first argument of a classmethod should be named ‘cls’
N805 first argument of a method should be named ‘self’
N806 variable in function should be lowercase
N807 function name should not start or end with ‘__’
   
N811 constant imported as non constant
N812 lowercase imported as non lowercase
N813 camelcase imported as lowercase
N814 camelcase imported as constant
N815 mixedCase variable in class scope
N816 mixedCase variable in global scope
yangsuiyun commented 4 years ago

https://www.cnblogs.com/ncwoniu/p/11512666.html Good way to name function

yangsuiyun commented 4 years ago

Clean Code

yangsuiyun commented 4 years ago

https://www.python.org/dev/peps/pep-0008/ Naming Conventions