Recusive function inside a function can't find itself.

Jeremy Hylton jeremy at cnri.reston.va.us
Sat Oct 23 14:10:29 EDT 1999


Python does not have nested scopes.  Each function looks in two
environments for name bindings -- its locals and its globals.  The
fact that the funcion in question is nested inside another function is
ignored in Python.  This implies a requirement that all recursive
functions be defined at the top level.  (In most Python code, all
functions are defined at the top level.)

And before you ask :-) -- You could spend the rest of the weekend
reading old threads about whether this should be changed.  If you're
interested check out DejaNews or the archives at Python.org.

Jeremy





More information about the Python-list mailing list