Skip to content

Instantly share code, notes, and snippets.

@pkulev
Created Jul 15, 2014
Embed
What would you like to do?
from abc import ABCMeta, abstractmethod
class Duck(object, metaclass=ABCMeta):
def quack(self):
print("Quack")
def swim(self):
print("I'm swimming!")
@abstractmethod
def display(self):
raise NotImplemented
# def fly(self):
# print("I'm flying!")
class MallardDuck(Duck):
def display(self):
print("MallardDuckRender")
class RubberDuck(Duck):
def quack(self):
print("Squeak!")
def display(self):
print("RubberDuckRender")
l = [MallardDuck(), RubberDuck()]
for i in l:
i.quack()
i.swim()
i.display()
# i.fly()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment