Nested functions. : nested function « Function « Python Tutorial






def outer():

   def inner():
      print "\nFunction inner executing"
      print "The objects in inner's scope are:", dir()
      print "Function inner finishing"

   print "Function outer executing"
   print "The objects in outer's scope are:", dir()
   inner()
   print "\nFunction outer finishing"

print "The objects in the global scope are:"
print dir()

print "\nCalling function outer\n"
outer()
print "\nFunction outer finished"








10.12.nested function
10.12.1.Number of Scopes
10.12.2.Simple Closure Example
10.12.3.Scope and lambda
10.12.4.Nested functions.