[Zope] Newbie - passing a list to an External Method
Passin, Tom
tpassin@mitretek.org
Thu, 17 Apr 2003 16:23:20 -0400
[ Dylan Reinhardt]
> Look extra carefully at any and all assignments you make in=20
> the external
> method. In particular, it's possible you may have committed a common
> error with lists, ex:
>=20
> a =3D [1,2.3]
> b =3D a
> b =3D None
> # now the value of a is None!
>=20
That is not right. a retains its value as expected. To prove it,
here's a transcript from an IDLE session, with Py2.1.3 -
>>> a =3D [1,2,3]
>>> b=3Da
>>> print b
[1, 2, 3]
>>> b=3DNone
>>> print a
[1, 2, 3]
>>>=20
Even when you start with=20
a=3Db=3D[1,2,3]
a still remains when you set b to None.
You must be mixing this up with some other situation in which both and b
have a reference to the same list, and a changed value in one then shows
up in the other. For example -
>>> a=3Db=3D[1,2,3]
>>> a.append(4)
>>> print b
[1, 2, 3, 4]
This is different from re-assigning the variable to reference something
else like None.
Cheers,
Tom P