learn python the hard way exercise 42 help

Raymond Hettinger python at rcn.com
Wed Mar 30 19:51:24 EDT 2011


On Mar 30, 6:48 am, neil harper <neilalt300... at gmail.com> wrote:
> http://pastie.org/1735028
> hey guys play is confusing me, i get how next gets the first room, which
> is passed when the instance of Game() is created, but how does it get
> the next room?

It might help show calling patterns if you added print statements to
the while loop:

   def play(self):
        next = self.start
        while True:
            room = getattr(self, next)
            print "--- Calling the method:", room, "---"
            next = room()
            print "--- That method returned:", next, "---"

Raymond



More information about the Python-list mailing list