[Tutor] function declaration problems perhaps?
keridee at jayco.net
Thu Jul 26 00:33:05 CEST 2007
> By the way, this is an important and fundamental subject about
> Python. When I teach classes on Python, I always need to explain
> Python's execution model, and I always struggle with it. So,
> anything you can tell me that would help me teach this will be much
The way I keep it clear is simple. If python needs the value of the name (it
has to look it up) then it had better be defined. Otherwise ~ It doesn't
Think of it like assignment.
x = 1
Does python need to know the current value of x? No. Then x does not have to
be previously defined.
Does python need to know the current value of f? Yes. It has to know that f
is a function, and where the address is, etc.
Does python need to know the current value of f? No. Not until f1 is
Does this help? Only one rule to remember. ;-) ~Does python need to know the
value of _this_ variable?~
More information about the Tutor