class GenericMaxException(Exception):
"""Base class for all Max layer exceptions."""
def __init__(self, *, message):
"""
Constructor.
Parameters:
Required:
message - String describing exception.
Optional:
None
"""
super().__init__(message)
为什么我们需要在超级传递信息。该消息是否为GenericMaxException从say Exception类继承的类中的任何函数的参数?我知道super正在引用基类属性。。但是无法理解为什么在super内部调用message参数
默认情况下,如果在引发异常时使用
super
没有传递任何内容,则没有任何解释,它只在回溯中显示引发异常的位置/行。但当引发异常时,传递消息给出了这种解释例1:
输出:
例2:
输出:
相关问题 更多 >
编程相关推荐