Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from typing import List
- class Parent:
- tags: List[str]
- def __init__(self):
- tag = 'parent'
- try:
- self.tags.append(tag)
- except AttributeError:
- self.tags = list([tag])
- class ChildA(Parent):
- def __init__(self):
- tag = 'child_a'
- try:
- self.tags.append(tag)
- except AttributeError:
- self.tags = list([tag])
- super().__init__()
- class ChildB(Parent):
- def __init__(self):
- tag = 'child_b'
- try:
- self.tags.append(tag)
- except AttributeError:
- self.tags = list([tag])
- super().__init__()
- class GrandChild(ChildA, ChildB):
- def __init__(self):
- super().__init__()
- if __name__ == '__main__':
- test = GrandChild()
- print(test.tags)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement