[Zope] passing lists as function parameters
Eric Roby
Eric.Roby@noaa.gov
Fri, 08 Nov 2002 06:33:11 -0600
Maybe I am really missing something here, but for some time, I have been
trying to figure out why when I pass a list to a python script, it
becomes a sequence of characters. When I duplicate the process within
the interpreter, it works as I expect it to. An example to demonstrate
what I am talking about:
Interpreter test-
>>> listDef = [1,2,3,4,5]
>>> def foo(x):
... for member in x:
.... print member
...
>>> foo(listDef)
1
2
3
4
5
>>>
In Zope, if I create the equivalent of the foo function in a python
script, passing a list in the parameter field, I get the following:
1
,
2
,
3
,
4
,
5
Or if I test the script with the following value for the parameter -
[1,2,3,4,5] - I get:
[
1
,
2
,
3
,
4
,
5
,
]
so ... len(theList) returns a value that represents the count of all
characters in the list definition - not the number of items in the list.
Any enlightenment here would be greatly appreciated. I hesitate to call
'BUG' cause it might be me that is 'buggy'...
TIA
Eric