> Hmm..If I add a few debugging lines like that into my code, I get this: >> > > The point was that statements in a class at class level (ie, not in defs) > are executed sequentially and expect referenced variables to exist (ie, > defined somewhere 'above' the current statement) -- there is no forward > peeking going on. Statements within def's (think 'deferred execution' if it > helps) expect that the variables referred to will exist by the time the def > is invoked. > > Python executes code top to bottom. def's create an executable object and > defers execution until invoked. Other statements execute when encountered. > The statements in your class that start > > Aside from other scattered problems with the code, Emile's explanation seems to get at the core of the OP's confusion. But I was wondering (for my own edification), can anyone point to the portion of the docs that clearly spells out the order of execution (top to bottom, classes vs. functions, etc.). The only place I've encountered such a discussion of execution order was in Chapter 2 of Pro Django, and the below doc pages don't seem to address the issue head-on (unless I'm misunderstanding or missed something):
http://docs.python.org/tutorial/classes.html http://docs.python.org/reference/executionmodel.html Thanks! Serdar
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor