我有Family
类和其继承的Person
类。我该如何从Person
类中获取familyName
属性?
class Family(object):
def __init__(self, familyName):
self.familyName = familyName
class Person(Family):
def __init__(self, personName):
self.personName = personName
例如,假设有以下这些
Family
和 Person
对象:strauss = Family('Strauss')
johaness = Person('Johaness')
richard = Person('Richard')
我想要做类似以下这样的事情:
print richard.familyName
并获取'Strauss'
。我该怎么做?