def get_doc(obj):
"""Get the doc string or comments for an object.
:param object: object
:returns: doc string
:rtype: str
>>> get_doc(abs)
'abs(number) -> number\\n\\nReturn the absolute value of the argument.'
"""
result = inspect.getdoc(obj) or inspect.getcomments(obj)
return result and RE_EMPTY_LINE.sub('', result.rstrip()) or ''
评论列表
文章目录