我目前是从 Python 开始的,我有很强的 PHP 背景,在 PHP 中我已经养成了将javadoc
其用作文档模板的习惯。
我想知道它是否在 Python 中javadoc
作为文档。这里的既定惯例和/或官方准则是什么?docstring
例如,像这样的东西过于复杂,不适合 Python 的思维方式,还是我应该尽量简洁?
"""
replaces template place holder with values
@param string timestamp formatted date to display
@param string priority priority number
@param string priority_name priority name
@param string message message to display
@return string formatted string
"""
如果我有点太详尽了,我应该改用这样的东西吗(大多数文档都没有通过该__doc__
方法打印出来)?
# replaces template place holder with values
#
# @param string timestamp formatted date to display
# @param string priority priority number
# @param string priority_name priority name
# @param string message message to display
#
# @return string formatted string
def format(self, timestamp = '', priority = '', priority_name = '', message = ''):
"""
replaces template place holder with values
"""
values = {'%timestamp%' : timestamp,
'%priorityName%' : priority_name,
'%priority%' : priority,
'%message%' : message}
return self.__pattern.format(**values)