setting variables in outer functions
Bruno Desthuilliers
bdesth.quelquechose at free.quelquepart.fr
Tue Oct 30 16:01:05 EDT 2007
brad a écrit :
> Tommy Nordgren wrote:
>
>>> def outer(avar=False):
>>> print avar
>>> if avar == True:
>>> return
>>>
>>> def inner(avar=True):
>>> print avar
>>> return avar
>>>
>>> outer(inner())
>>>
>>> outer()
>
>
>> This is not a general solution to this problem.
>
>
> Run my example code, it works (if I'm understanding your question
> correctly). It sets outer to True... inner returns True to outer and
> thus the var is set... am I missing something?
Yes: you forgot to rebind avar in inner and check the result in outer.
More information about the Python-list
mailing list