nested functions
Kent Johnson
kent at kentsjohnson.com
Fri Apr 14 08:05:17 EDT 2006
micklee74 at hotmail.com wrote:
> hi
> just curious , if i have a code like this?
>
> def a():
> def b():
> print "b"
> def c():
> print "c"
>
> how can i call c() ??
c is a name in the local scope of a(). You can call c from within a,
where the name is in scope, or you can return c or in some other way
make the value available in some other scope:
In [5]: def a():
...: def c():
...: print 'called c'
...: c()
...: return c
...:
In [6]: cc=a()
called c
In [7]: cc()
called c
Kent
More information about the Python-list
mailing list