# 正确的模块名
import decoder
import html_parser
# 不推荐的模块名
import Decoder
-特殊的如init模块,如果模块是包的私有模块会使用前缀加一个下划线。包也是一样
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
def __init__(self):
pass
def __add__(self):
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_)
6、一些命名习惯
is_life=True#是否活着
is_connected=True#是否连接
has_cache=True#是否有内存
users=['zhangsan','lisi']
# 个人地址用全称
persons_addresses={'zhangsan':'beijing','lisi':'shanghai'}