Python等同于PHPDoc块?
我是来自PHP的Python新手,我知道Python有docstring,但如何在类变量上实现这一点?假设在PHP中,我有:Python等同于PHPDoc块?,php,python,python-3.x,docstring,docblocks,Php,Python,Python 3.x,Docstring,Docblocks,我是来自PHP的Python新手,我知道Python有docstring,但如何在类变量上实现这一点?假设在PHP中,我有: class Animal { /** * @var Noise */ public $noise } 现在我该如何实现这一点呢?比如: class Animal: # Here I want to tell my IDE that this is a noise object, not yet set self.noise =
class Animal {
/**
* @var Noise
*/
public $noise
}
现在我该如何实现这一点呢?比如:
class Animal:
# Here I want to tell my IDE that this is a noise object, not yet set
self.noise = None
这些称为属性docstring。您可以将docstring放在类的声明之后,或者放在_init__方法中: 发件人: 在 模块、类或init方法的顶层称为属性 文档字符串 另见
这方面有很多资源,只需搜索属性Docstring,例如。我已经使用了三个单引号、我的信息和三个单引号。在这种情况下,我是否应该更正像get_noise这样返回self.noise的函数,并在那里添加Docstring?