该写法根据Python的PEP 257文档总结. 类的函数称为方法(method),模块里的函数称为函数(function) 每一个包,模块,类,函数,方法都应该包含文档,包括类的__init__方法 包的文档写在__init__.py文件中 文档有单行文档和多行文档 单行文档: 不要重复函数的声明语句,例如:function(a, b) -> list 指明做什么和返回什么,例如Do X and return a list. 使用三引号,方便换行 多行文档: 如果模块是一个脚本,也就是单文件程…
在python的官方文档中:getattr()的解释如下: getattr(object, name[, default]) Return the value of the named attribute of object. name must be a string. If the string is the name of one of the object’s attributes, the result is the value of that attribute. For examp…