setting variables in outer functions

brad byte8bits at gmail.com
Mon Oct 29 21:59:10 CET 2007


Tommy Nordgren wrote:
> Given the following:
> def outer(arg)
>      avar = ''
>      def inner1(arg2)
>           # How can I set 'avar' here ?

Try this... works for me... maybe not for you?

def outer(avar=False):
     print avar
     if avar == True:
         return

     def inner(avar=True):
         print avar
         return avar

     outer(inner())

outer()



More information about the Python-list mailing list