比较与继承
在本练习中,您将检验当父类的对象与子类的对象进行比较时会发生什么。
请看下面这两个类,已在 script.py 中实现并可供您使用:
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__() 方法,并包含用于诊断的打印输出。
本练习是课程的一部分
