在python3中的docstring中插入异常和异常类型的最佳做法是什么?
我使用这种模式:
def get_platform(cls, platform, channel):
"""
Get specific plafform in BotMachine list
:param str from const in BotMachine platform: type of platform
:param str channel: id of channel in platform
:return: messaging platform
:rtype: MessagingPlatform
:raise Exception: platform not found
"""
Pycharm接受这种格式并以正确的方式呈现Exception,但我如何插入Except类型?
如果使用会引发什么是正确的方式?
"""
Comment
:raises Exception: platform not found|argument not found
"""
答案 0 :(得分:0)
:raises:
Exception: Explanation here.
# or
:raises Exception: Explanation here.
其中Exception
可以用异常类型替换(例如ValueError: Explanation here.
)