RE: [Zope] Newbie - passing a list to an External Method
[ Dylan Reinhardt]
Look extra carefully at any and all assignments you make in the external method. In particular, it's possible you may have committed a common error with lists, ex:
a = [1,2.3] b = a b = None # now the value of a is None!
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 = [1,2,3] b=a print b [1, 2, 3] b=None print a [1, 2, 3]
Even when you start with a=b=[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=b=[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
On Thu, 2003-04-17 at 13:23, Passin, Tom wrote:
[ Dylan Reinhardt]
a = [1,2.3] b = a b = None # now the value of a is None!
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 -
Ugh... there's nothing like making a newbie error when you try to point out a newbie error. I probably shouldn't speculate and offer help at the same time. Thanks for keeping me honest. :-)
This is different from re-assigning the variable to reference something else like None.
You're right... no amount of in-place changes to a list object will probably produce the error the OP is seeing. Theorizing how that change might have been a side effect of something else was just off-base. But we can still go back to theory #1: something in that external method is *directly* re-assigning the "lines" variable to a non-sequence type like None. Dylan
participants (2)
-
Dylan Reinhardt -
Passin, Tom