The python named

Naming suggestions:

module_name, package_name, ClassName, method_name, ExceptionName, 
function_name, GLOBAL_VAR_NAME, instance_var_name, function_parameter_name, local_var_name.

The name should be avoided:

  • Single-character names, in addition to the counter and iterators.
  • Package / module name hyphen (-)
  • The beginning and the end of the double underscore name (Python reserved, for example, __init__)

Naming conventions:

  • The so-called "internal (Internal)" indicates only available within the module, or in the class is protected or private.
  • Single underscore (_) at the beginning of a block of variable or function is protected (not included when using from module import *).
  • Double-underlined (__) method or instance variables represents the beginning of the kind of private.
  • The related classes and top-level functions in the same module. Unlike Java, a class is not necessary to limit a module.
  • The use of class names begin with a capital letter word (such as CapWords, namely Pascal style), but the module name should be in lower case underlined the way (such as lower_with_under.py). Although there are many existing modules such use similar CapWords.py named, but now is not encouraged, because if it happens module name and the name of the same class, which will be annoying.

Reference links:

[1] https://zh-google-styleguide.readthedocs.io/en/latest/google-python-styleguide/python_style_rules/

Guess you like

Origin www.cnblogs.com/yunxiaofei/p/11210270.html