Help: Python while loop inside Class
<p>I'm just learning Python as my first programming language, and going through the <a href="http://learnpythonthehardway.org/book/ex42.html" rel="nofollow">this online book</a>.  My problem relates to the exercise found on that page.  I'm stuck understanding how the play method works inside the class.  How is it accessing all the other methods?  How is getattr functioning inside this loop?  Appreciate the help!</p>

<p>Here is the method for those that would prefer not to leave the page:</p>

<pre><code>def play(self):
    next = self.start

    while True:
        print "\n--------"
        room = getattr(self, next)
        next = room()
</code></pre>
