Created
June 24, 2015 14:11
-
-
Save avian2/c6dd0d758c4d16e1b92a to your computer and use it in GitHub Desktop.
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
# pizza.py | |
class DoughFactory(object): | |
def get_dough(self): | |
return 'insecticide treated wheat dough' | |
class Pizza(DoughFactory): | |
def order_pizza(self, *toppings): | |
print('Getting dough') | |
dough = super().get_dough() | |
print('Making pie with %s' % dough) | |
for topping in toppings: | |
print('Adding: %s' % topping) | |
if __name__ == '__main__': | |
Pizza().order_pizza('Pepperoni', 'Bell Pepper') | |
# better_pizza.py | |
from pizza import Pizza, DoughFactory | |
class OrganicDoughFactory(DoughFactory): | |
def get_dough(self): | |
return 'pure untreated wheat dough' | |
class OrganicPizza(Pizza, OrganicDoughFactory): | |
pass | |
if __name__ == '__main__': | |
OrganicPizza().order_pizza('Sausage', 'Mushroom') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment