[Zope] PythonScript -> List item is out of range

Peter Bengtsson mail@peterbe.com
Fri, 8 Jun 2001 15:31:48 +0200


To say this:
s1['a'] and s1['b']
is the same thing as saying this:
if s1['a'] and s1['b']:

so return s2 should return
{'a':0} since not both s1['a'] and s1['b'] are true.

+ adds s1['a'] and s1['b'] as if they were integers.

Did that help? or am I on the wrong track.

>
> Hi:
>
> I wrote this PythonScript:
>
> s1 = { 'a': 1, 'b': 0 }
> s2 = { 'a': s1['a'] and s1['b'] }
> return s2
>
> and Zope does not accept this. Zope returns directly
> a list item is out of range...
>
> When I replace the 'and' by '+', then everything is ok!
>
> How to do ?
>
>
>
> ---
>    "I suppose if we couldn't laugh at things that don't make sense, we
couldn't
> react to a lot of life."  -Hobbes
> ---
>  Oliver Pabst             .-------------------------.
>  mailto:olpa@sybcom.de    :                         :
>  phone :+49 681 56600600  :    project department   :          SYBCOM GmbH
>  fax   :+49 681 56600660  :                         : http://www.sybcom.de
>
>
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )