PythonScript -> List item is out of range
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
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 )
From: <olpa@sybcom.de>
s1 = { 'a': 1, 'b': 0 } s2 = { 'a': s1['a'] and s1['b'] } return s2
Some versions of the PythonScripts Product don't properly handle a mixture of subobject access and boolean operators. You can rewrite this as: s1 = { 'a': 1, 'b': 0 } s1a = s1['a'] s1b = s1['b'] s2 = { 'a': s1a and s1b } return s2 I think this is fixed in Zope 2.3.2. Cheers, Evan @ digicool
On Today, Evan Simpson wrote:
From: <olpa@sybcom.de>
s1 = { 'a': 1, 'b': 0 } s2 = { 'a': s1['a'] and s1['b'] } return s2
Some versions of the PythonScripts Product don't properly handle a mixture of subobject access and boolean operators. You can rewrite this as:
s1 = { 'a': 1, 'b': 0 } s1a = s1['a'] s1b = s1['b'] s2 = { 'a': s1a and s1b } return s2
that's a good workaround, and worked for me.
I think this is fixed in Zope 2.3.2.
Cheers,
Evan @ digicool
I was using 2.3.2. Thanks for your help. I still think there is a bug in the apple... --- "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
participants (3)
-
Evan Simpson -
olpa@sybcom.de -
Peter Bengtsson