why is this not working? (nested scope question)

John Salerno johnjsal at NOSPAMgmail.com
Wed Jul 26 22:04:19 EDT 2006


biner.sebastien at ouranos.ca wrote:

> I do understand (and verified) that if I define f2 within f1, it works
> as expected. But in the "learning pyton 2nd edition" at page 205 it is
> said that "Programs are much simpler if you do not nest defs within
> defs" (juste before the code mentioned in my initial message).

Actually, the code in the book is:

def f1():
     x = 88
     f2(x)

def f2(x):
     print x

f1()

which makes all the difference in the world. Not to mention that this 
particular section of the book is giving an example of how to write the 
code *without* using nested functions.



More information about the Python-list mailing list