比較と継承
この演習では、親クラスのオブジェクトを子クラスのオブジェクトと比較したときに何が起きるかを確認します。
次の2つのクラスが 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__() メソッドを実装しています。
この演習はコースの一部です
