why is this not working? (nested scope question)

John Salerno johnjsal at NOSPAMgmail.com
Thu Jul 27 10:33:24 EDT 2006


biner.sebastien at ouranos.ca wrote:

> Ouch! You got me there, I did not copy the code properly. Now I feel
> stupid. Thanks for the enlightment.
> 
> I think I am starting to get it.

P.S. The point of the example was to show how nesting isn't necessary 
much of the time. The authors wanted to show that it is okay to write a 
call to f2 before f2 is even defined, as long as f2 is defined before 
that call is actually executed, i.e. when f1() is called. Keeping the 
two functions separate is cleaner than nesting, and passing parameters 
is how you get around the local scope issue.



More information about the Python-list mailing list