GeezerVison is showing github.com — Python-2/Article/codeSpecification/codeSpecification_third.md at master · leiaoo/Python-2
/
codeSpecification_third.md
Copy path 82 lines (56 loc) · 1.32 KB
/
codeSpecification_third.md
Copy pathFile metadata and controls
82 lines (56 loc) · 1.32 KB
Copy raw file
Download raw file
OutlineEdit and raw actions
- 模块尽量使用小写命名,首字母保持小写,尽量不要用下划线(除非多个单词,且数量不多的情况)
# 正确的模块名
import decoder
import html_parser
# 不推荐的模块名
import Decoder
- 类名使用驼峰(CamelCase)命名风格,首字母大写,私有类可用一个下划线开头
class Farm():
pass
class AnimalFarm(Farm):
pass
class _PrivateFarm(Farm):
pass
- 将相关的类和顶级函数放在同一个模块里. 不像Java, 没必要限制一个类一个模块.
def run():
pass
def run_with_env():
pass
class Person():
def _private_func():
pass
if __name__ == '__main__':
count = 0
school_name = ''
MAX_CLIENT = 100
MAX_CONNECTION = 1000
CONNECTION_TIMEOUT = 600
MAX_OVERFLOW = 100
Class FooBar:
def foo_bar(self, print_):
print(print_)