Python question on parse routines with dicts, while loops, and assignments
<p>I have some code from a much-maligned Python resource, if you ask SO, but I am trying to divine Python’s parse routine from it, regardless its didactic merits.</p>

<pre><code>def princess_lives_here():
    #&lt;some messages and conditionals to keep you going in the text-based game&gt;
    #&lt;one of the conditionals end in a `return 'death'`, another function in ROOMS&gt;

ROOMS = {
    'death': death,
    'princess_lives_here': princess_lives_here,
}

def runner (map, start):
    next = start

    while True:
        room = map[next]
        print "\n--------"
        next = room()

runner(ROOMS, 'princess_lives_here')
</code></pre>

<ol>
<li><p>What I am not sure about is how <code>princess_lives_here</code> is ever run in the while loop. I can only assume that it is run is the last line, but what looks like an assignment to me must be an execution of <code>room()</code>, i.e. <code>princess_lives_here</code>. Why, when and how is this execution performed?</p></li>
<li><p>My second question is how, when, and why the while loop is run again, when the parsing routines hits <code>return 'death'</code>.</p></li>
</ol>

<p>I’ve created a gist with the entire code, in case you want the greater picture. It just takes up a lot of lines of code: <a href="https://gist.github.com/848228" rel="nofollow">https://gist.github.com/848228</a>.</p>
