Skip to content

Instantly share code, notes, and snippets.

@sharpblade4
Last active June 22, 2020 08:09
Show Gist options
  • Save sharpblade4/b26fbe0d37d51820d06e2720353af564 to your computer and use it in GitHub Desktop.
Save sharpblade4/b26fbe0d37d51820d06e2720353af564 to your computer and use it in GitHub Desktop.
cooperative multiple inheritance paradigm in python
class Vehicle:
def __init__(self, color: str) -> None:
self._color = color
class ConstructionMachine:
def __init__(self) -> None:
super().__init__()
def rumble(self) -> str:
return 'zzz' + super().__str__()
class Tractor(ConstructionMachine, Vehicle):
def __init__(self, color: str) -> None:
Vehicle.__init__(self, color)
ConstructionMachine.__init__(self)
if __name__ == '__main__':
Tractor('yellow')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment