Code practice
1 Python
1.1 避免魔术数字
# BAD
if cluster_type == 1:
pass
# GOOD
class enum_cluster_type(object):
""""""
K8S = 1
Mesos = 2
if cluster_type == enum_cluster_type.K8S:
pass1.2 不要预计算字面量表达式
1.3 优先使用列表推导或内联函数
1.4 当在非测试代码中使用 assert 时,妥善添加断言信息
assert 时,妥善添加断言信息2 Butterfly
2.1 command 执行时默认展示 table,接口请求时展示 json
Last updated