Last active
June 22, 2020 08:09
-
-
Save sharpblade4/b26fbe0d37d51820d06e2720353af564 to your computer and use it in GitHub Desktop.
cooperative multiple inheritance paradigm in python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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