nested functions

Fredrik Lundh fredrik at pythonware.com
Fri Apr 14 10:10:51 EDT 2006


micklee74 at hotmail.com wrote:

> just curious , if i have a code like this?
>
> def a():
>   def b():
>     print "b"
>   def c():
>     print "c"
>
> how can i call c() ??

in the same way as you'd access the variable "c" in this example:

    def a():
        c = 10

(that is, by calling the function and accessing the local variable "c"
from the inside.  in both cases, "c" lives in the local namespace, and
doesn't exist at all unless you call the function).

</F>






More information about the Python-list mailing list