<br>On Mon, Nov 23, 2009 at 10:26 AM, j <span dir="ltr"><<a href="mailto:jimmy.casey.3@gmail.com">jimmy.casey.3@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

What I am not totally sure about is when the store function callsthe<br>
lookup function and does "return data[label].get(name)", that line<br>
"trips" me up some....then the lookup function returns that back to<br>
the store function, assigns the data to the variable 'people', THEN<br>
does this, which also isn't that clear to me what it's all doing:<br>
<br></blockquote><div><br></div><div>It does it right when it hits it in the code; basically, the for loop runs over the list of items from the zip.</div><div><br></div><div>In each one, it calls the lookup function. Execution then jumps over to lookup. Once the lookup function is done ('returns' or hits its it), execution jumps right back with a result, and that result is stored int he 'people' variable.  </div>

<div><br></div><div>Then the next item in the for loop is processed; again, when the function() is called, execution jumps over to that again, and so on.</div><div><br></div><div>Only when all the things are done in the for loop, does execution move on to...</div>

<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
if people:<br>
    people.append(full_name)<br>
else:<br>
<div class="im">    data[label][name] = [full_name]<br>
<br></div></blockquote><div><br></div><div>Basically, "lookup" will return one of two things.</div><div><br></div><div>If someone with the given part of a name already has been stored, it'll return a list containing the people with that name.</div>

<div><br></div><div>Otherwise, it will return None.</div><div><br></div><div>The if/else above will operate on those two conditions: if 'lookup' returned a list of people, its going to add this person to that list. If it doesn't return a list of people, it's going to add this persons name to the data dictionary as a new list. So anyone in the future who has that name will find them on lookup.</div>

<div><br></div><div>The thing is, I think lines 105-108 should be indented deeper one level to be 'inside' the for loop; and thus called with each execution, and not only after the for is all done with. As it is, it seems like a bug. Or I don't get at all what the point of the code is :)</div>

<div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">
</div>My main problem is finding out what's it's actually *doing*? I know<br>
and understand the terminologies (what 'append' does, what a<br>
'sequence' is, a 'list', a 'tuple', 'if'...'else'...etc...et....)<br></blockquote><div><br></div><div>I concur with the other people who say this is bad code to learn from; the book could be a LOT clearer. I'd try another resource.. the online Python tutorial is a good place to start. A different book may be in order :)</div>

<div><br></div></div><br clear="all"><div name="mailplane_signature">--S</div>