[Python][TIP] python naming convention, naming rule
Naming
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.
Names to Avoid
single character names except for counters or iterators
dashes (-) in any package/module name
__double_leading_and_trailing_underscore__ names (reserved by Python)
Naming Convention
"Internal" means internal to a module or protected or private within a class.
Prepending a single underscore (_) has some support for protecting module variables and functions (not included with import * from). Prepending a double underscore (__) to an instance variable or method effectively serves to make the variable or method private to its class (using name mangling).
Place related classes and top-level functions together in a module. Unlike Java, there is no need to limit yourself to one class per module.
Use CapWords for class names, but lower_with_under.py for module names. Although there are many existing modules named CapWords.py, this is now discouraged because it's confusing when the module happens to be named after a class. ("wait -- did I write import StringIO or from StringIO import StringIO?")
Guidelines derived from Guido's Recommendations
Type Public Internal
Packages lower_with_under
Modules lower_with_under _lower_with_under
Classes CapWords _CapWords
Exceptions CapWords
Functions lower_with_under() _lower_with_under()
Global/Class Constants CAPS_WITH_UNDER _CAPS_WITH_UNDER
Global/Class Variables lower_with_under _lower_with_under
Instance Variables lower_with_under _lower_with_under (protected) or __lower_with_under (private)
Method Names lower_with_under() _lower_with_under() (protected) or __lower_with_under() (private)
Function/Method Parameters lower_with_under
Local Variables lower_with_under
Main
출처: https://chobokkiri.tistory.com/25?category=656553 [초보끼리]
'Python > Python 프로그래밍' 카테고리의 다른 글
파이썬을 이용한 selenium 사용법 및 동적 웹 스크래핑 (0) | 2021.03.27 |
---|---|
회사 프록시 때문에 pip, npm을 통해 제대로 패키지 다운로드가 안 될 때 (0) | 2021.03.27 |
파이썬 웹 스크래핑할 때 이거 쓰세요. 최고의 파이썬 웹 스크래핑 솔루션 scrapy (0) | 2021.03.27 |
[Python, 파이썬] Call by assignment, mutable, immutable, 파이썬 복사(Python Copy) (0) | 2021.03.27 |
[Python][TIP]virtualenv 개발 환경 구축 (0) | 2021.01.06 |
[Python][TIP] 소수점 중 불필요한 0 제거 하기 (0) | 2021.01.06 |
[Python][TIP] python 문자열(String) 특수 문자 제거 (0) | 2021.01.06 |
[Python][TIP] python map function (map 함수 사용하기) (0) | 2021.01.06 |