e-mail address change (was Re: [Tutor] python's default argument
value handling in functions - weird syntax? problem grappling with
the concept)
Ismael Garrido
ismaelgf at adinet.com.uy
Thu Feb 10 04:07:11 CET 2005
Danny Yoo wrote:
>###
>
>def f(a,L=[]):
> if L==[5]:
> print 'L==[5] caught'
> print L
> print 'resetting L...'
> L=[]
> L.append(a)
> return L
>
>
>###
>
Now I'm dizzy... I can't understand why there are two "L"!
L is a local variable of the function, right? (I can't imagine it being
anything else) Then if I reassign L to something, why doesn't it keep
that change till next run? At least, it keeps the values in the list..
so it should keep the reassignation, no?
I'm completly puzzled :-S
Ismael
More information about the Tutor
mailing list