如何访问对象中的实例并将其传递给另一个“主”对象?我正在使用解析器来解析不同标签的文件,INDI(个人),BIRT(事件),FAMS(配偶),FAMC(孩子)
基本上有三个类:Person,Event,Family
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 类中。我对类和类继承如何工作知之甚少。请帮忙!