In Learn Python The Hard Way exercise 43, there is a list in the class called quips
class Death(Scene):
quips = [
"You died. You kinda suck at this.",
"Your mom would be proud...if she were smarter.",
"Such a luser.",
"I have a small puppy that's better at this."
]
def enter(self):
print Death.quips[randint(0, len(self.quips)-1)]
exit(1)
Why isn't it assigned to self? I can't get my head around an explanation I saw on Reddit:
"Note the lack of any reference to self
? That means that
there's no instance involved. This is an attribute of the class. It's like writing on the blueprint instead of on the wall of your house. The class/blueprint "owns" the quips
attribute. The attribute is an otherwise uninteresting list
object. Because of the name resolution, instances can refer to this object as well: "