我使用很多代码模式:
1 class myTest():
2 counter = 0 # use this as general counter
3 name_code = '' # this is the name encoded using the
4 # standard as defined in ...
5 category = '' # category of test
第4行不是PEP8标准。 #应该在第5个位置,它看起来很难看:
3 name_code = '' # this is the name encoded using the
4 # standard as defined in ...
您如何评论这种模式?什么是最佳做法?
我将其作为docstrings进行处理,因此实际上它们可用于Sphinx等其他工具,并可用于例如生成文档:
class myTest():
counter = 0
"""use this as general counter"""
name_code = ''
"""this is the name encoded using the standard as defined in ..."""
category = ''
"""category of test"""
Docstrings通常是多行字符串,因此可以根据需要扩展为多行。