比较与继承
当一个对象与其子类的对象进行比较时会发生什么?请看下面两个类:
class Parent:
def __eq__(self, other):
print("Parent's __eq__() called")
return True
class Child(Parent):
def __eq__(self, other):
print("Child's __eq__() called")
return True
Child 类继承自 Parent 类,且两者都实现了包含诊断性打印输出的 __eq__() 方法。
本练习是课程的一部分
