【python】检查class类型时,报object没有属性错误

原因:点__class__时,漏写了后面两个下划线

    if data.__class.__base__ is not Optional:
AttributeError: 'WhereOptional' object has no attribute '_Optional__class'

 正确:

if data.__class__.__base__ is not Optional:
    raise TypeError('函子的返回类型必须是Option的子类')
return data
原文地址:https://www.cnblogs.com/GothicLolita/p/13053236.html