-
-
Save stephengruppetta/d630bda199d54ca38782a1824a502d27 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
# schools.py | |
from hogwarts_magic import House | |
class Hogwarts: | |
_houses = { | |
"Gryffindor": House( | |
"Gryffindor", "Godric Gryffindor", ["scarlet", "gold"], "lion" | |
), | |
"Slytherin": House( | |
"Slytherin", "Salazar Slytherin", ["green", "silver"], "serpent" | |
), | |
"Ravenclaw": House( | |
"Ravenclaw", "Rowena Ravenclaw", ["blue", "bronze"], "eagle" | |
), | |
"Hufflepuff": House( | |
"Hufflepuff", "Helga Hufflepuff", ["yellow", "black"], "badger" | |
), | |
} | |
@classmethod | |
def get_house(cls, house_name): | |
return cls._houses.get(house_name) | |
hogwarts_1 = Hogwarts() | |
hogwarts_2 = Hogwarts() | |
gryffindor_1 = hogwarts_1.get_house("Gryffindor") | |
gryffindor_2 = hogwarts_2.get_house("Gryffindor") | |
print(f"Is hogwarts_1 the same instance as hogwarts_2?\n" | |
f"{hogwarts_1 is hogwarts_2}") | |
print(f"Is gryffindor_1 the same instance as gryffindor_2?\n" | |
f"{gryffindor_1 is gryffindor_2}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment