learn python the hard way exercise 42 help

Discussion in 'Python' started by neil harper, Mar 30, 2011.

  1. neil harper

    neil harper Guest

    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?

    thanks
    neil harper, Mar 30, 2011
    #1
    1. Advertising

  2. On Mar 30, 6:48 am, neil harper <> 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
    Raymond Hettinger, Mar 31, 2011
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Porky Pig Jr
    Replies:
    3
    Views:
    1,017
    Fuzzyman
    May 12, 2004
  2. wen
    Replies:
    8
    Views:
    293
    Magnus Lycka
    Sep 2, 2005
  3. Zed Shaw
    Replies:
    0
    Views:
    345
    Zed Shaw
    Sep 29, 2010
  4. Joseph Sanoyo
    Replies:
    7
    Views:
    761
    John Bokma
    Apr 1, 2011
  5. eryksun ()
    Replies:
    0
    Views:
    660
    eryksun ()
    Mar 31, 2011
Loading...

Share This Page