Created
March 3, 2016 20:34
-
-
Save drvinceknight/f429562b36a270431c16 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Pet: | |
noise = "" | |
def make_noise(self): | |
return self.noise | |
class Dog(Pet): | |
noise = "Woof" | |
class Cat(Pet): | |
noise = "Meow" | |
class Tortoise(Pet): | |
noise = "Rock" | |
bingo = Cat() | |
print bingo.make_noise() | |
animal_classes = {"cat": Cat, "dog": Dog, "rock": Tortoise} | |
print animal_classes | |
wanted_class = "dog" | |
auraya = animal_classes[wanted_class]() | |
print auraya.make_noise() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment