Created
May 27, 2018 05:53
-
-
Save automationhacks/f82126b921e80519c9fb19d95f6556e7 to your computer and use it in GitHub Desktop.
Illustrates duck typing in the simplest way
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 Duck: | |
def quack(self): | |
print("Quacked") | |
class AnotherDuck: | |
def quack(self): | |
print("Louder Quack") | |
class Eagle: | |
def fly(self): | |
print("Dude i just fly") | |
class MakeItQuack: | |
def __init__(self, bird): | |
bird.quack() | |
MakeItQuack(Duck()) | |
MakeItQuack(AnotherDuck()) | |
MakeItQuack(Eagle()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment