I've done some reading and can't grasp this as fully as I'd like to. I'm making a little "choose your own adventure" game from the LPTHW tutorial, here's the full script: http://codepad.org/YWVUlHnU
What I don't understand is the following:
class Game(object):
def __init__(self, start):
self.quips = [
"You died. Please try again.",
"You lost, better luck next time.",
"Things didn't work out well. You'll need to start over."
"You might need to improve your skills. Try again."
]
self.start = start
I get that we're creating a class, but why define __init__
? Later on I do stuff like print self.quis[randint(0, len(self.quips)-1)]
which prints one of the four strings in quips
, but why wouldn't I just create a function called quips
or something?