why is this not working? (nested scope question)

biner.sebastien at ouranos.ca biner.sebastien at ouranos.ca
Wed Jul 26 16:33:07 EDT 2006


Thanks for the answers.

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).

In a way, I though the local variables of f1 would in a way add to the
global variable of f2 (because f1 called f2) and that f2 would look in
the global variables when it could not find a variable locally
(following the LEGB rule).

Still the code I put is presented in the book and it does not work for
me. I googled for errata regarding that code but did not find any.

Sébastien.




More information about the Python-list mailing list