Re: [Zope] how do I test for the current item in an iteration

2007-09-28 Thread Andreas Jung



--On 28. September 2007 16:36:43 +0100 kamal hamzat 
[EMAIL PROTECTED] wrote:



Dear All,

I have this error after i added the if statement

Error Type: TypeError
Error Value: mybrains.__cmp__(x,y) requires y to be a 'mybrains', not a
'int'


for i in context.zCatNewsCurrent():
 if i = 5:
print %s: %s: %s % (i.id, i.author, i.summary)

return printed


Look at Python's enumerate() method.

-aj

pgp9ZLwhXwqLz.pgp
Description: PGP signature
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] how do I test for the current item in an iteration

2007-09-28 Thread kamal hamzat
Dear All,

I have this error after i added the if statement

Error Type: TypeError
Error Value: mybrains.__cmp__(x,y) requires y to be a 'mybrains', not a 'int'


for i in context.zCatNewsCurrent():
 if i = 5:  
print %s: %s: %s % (i.id, i.author, i.summary)

return printed



Pls help

kamal





Error Type: TypeError
Error Value: mybrains.__cmp__(x,y) requires y to be a 'mybrains', not a 'int'

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] how do I test for the current item in an iteration

2007-09-28 Thread Andrew Milton
+---[ kamal hamzat ]--
| Dear All,
| 
| I have this error after i added the if statement

Time for you to do some reading of your own.

That's three in less than an hour...

-- 
Andrew Milton
[EMAIL PROTECTED]
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] how do I test for the current item in an iteration

2007-09-28 Thread Dieter Maurer
kamal hamzat wrote at 2007-9-28 16:36 +0100:
I have this error after i added the if statement

Error Type: TypeError
Error Value: mybrains.__cmp__(x,y) requires y to be a 'mybrains', not a 'int'


for i in context.zCatNewsCurrent():
 if i = 5:  
print %s: %s: %s % (i.id, i.author, i.summary)

You are aware that you use i both as an integer (i = 5)
as well as a structure (i.id, i.author, ...).

Python is quite polymorph -- but there are some limits.

Andreas suggestion was good: enumerate may help you...



-- 
Dieter
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )