|
@@ -119,6 +119,24 @@ class Person:
|
|
|
if getattr(person, attr) is not None:
|
|
|
setattr(self, attr, getattr(person, attr))
|
|
|
|
|
|
+ @property
|
|
|
+ def parents(self) -> typing.Tuple["Person"]:
|
|
|
+ """
|
|
|
+ >>> p = Person("max")
|
|
|
+ >>> p.parents
|
|
|
+ ()
|
|
|
+ >>> p.mother = Person("mum")
|
|
|
+ >>> p.parents
|
|
|
+ (Person(mum),)
|
|
|
+ >>> p.father = Person("dad")
|
|
|
+ >>> p.parents
|
|
|
+ (Person(mum), Person(dad))
|
|
|
+ >>> p.mother = None
|
|
|
+ >>> p.parents
|
|
|
+ (Person(dad),)
|
|
|
+ """
|
|
|
+ return tuple(filter(None, [self.mother, self.father]))
|
|
|
+
|
|
|
|
|
|
class PersonCollection:
|
|
|
|