setting variables in outer functions

brad byte8bits at gmail.com
Mon Oct 29 16:59:10 EDT 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