[Tutor] re: Scoping question

Thomas Zirnsack tzirnsack@web.de
Mon, 9 Sep 2002 20:15:39 +0200


> > And finally, why does the assignment to a list element execute
> > successfully?
>
> It doesn't for me. Maybe it's your choice of keyword.
Well, as I tested:
----->8-----
l =3D [0,2,3]

def foo()
   l[0] +=3D 1

foo()
print l
----->8-----
Will print -> [1,2,3]

I assume this works by design and not accidently
by choosing a var name like 'list' (python 2.2 here).

just my 5 cents,
tom