Skip to content

Instantly share code, notes, and snippets.

@automationhacks
Created May 27, 2018 05:53
Show Gist options
  • Save automationhacks/f82126b921e80519c9fb19d95f6556e7 to your computer and use it in GitHub Desktop.
Save automationhacks/f82126b921e80519c9fb19d95f6556e7 to your computer and use it in GitHub Desktop.
Illustrates duck typing in the simplest way
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