オブジェクト内のインスタンスにアクセスして、それを別の「メイン」オブジェクトに渡すにはどうすればよいですか? INDI(個人)、BIRT(イベント)、FAMS(配偶者)、FAMC(子供)など、さまざまなタグを解析するファイルのパーサーを使用しています。
基本的に、Person、Event、Family の 3 つのクラスがあります。
class Person():
def __init__(self, ref):
self._id = ref
self._birth : None
def addBirth(self, event):
self._birth: event
class Event():
def __init__(self, ref):
self._id = ref
self._event = None
def addEvent(self, event):
self._event = event
#**event = ['12 Jul 1997', 'Seattle, WA'] (this is generated from a function outside a class)
self._event を Event クラスから addBirth メソッドに転送して、person クラスに追加したいと考えています。クラスとクラスの継承がどのように機能するかについて、私はほとんど知識がありません。助けてください!