[Zope] passing lists as function parameters
Dieter Maurer
dieter@handshake.de
Fri, 8 Nov 2002 23:23:13 +0100
Eric Roby writes:
> 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
You do not pass a list here but a string and you iterate over
the bytes of the string.
When you would pass a true list and not just a string that looks like
(the string representation of) a list, then it would work as
you expect.
Dieter