魔术方法 调用方式 解释 __new__(cls [,...]) instance = MyClass(arg1, arg2) __new__ 在创建实例的时候被调用 __init__(self [,...]) instance = MyClass(arg1, arg2) __init__ 在创建实例的时候被调用 __cmp__(self, other) self == other, self > other, 等. 在比较的时候调用 __pos__(self) +self 一元加运算符 __n…