FAQ
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

Search Discussions

  • Eryksun () at Mar 30, 2011 at 2:24 pm

    On Wednesday, March 30, 2011 9:48:29 AM UTC-4, 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?

    thanks
    Each room is a method of Game. The returned value of each room is a reference to another room, depending on some condition. play() just loops the following: call room(); store the return reference as next; assign next to room. This continues until death(), which randomly insults you and quits.
  • Raymond Hettinger at Mar 30, 2011 at 11:51 pm

    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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedMar 30, '11 at 1:48p
activeMar 30, '11 at 11:51p
posts3
users3
websitepython.org

People

Translate

site design / logo © 2018 Grokbase