From: SourceForge.net <no...@so...> - 2003-06-26 13:32:39
|
Bugs item #761177, was opened at 2003-06-26 13:32 Message generated for change (Settings changed) made by emcastro You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=112867&aid=761177&group_id=12867 Category: Core Group: None Status: Open Resolution: None Priority: 5 Submitted By: Emmanuel Castro (emcastro) Assigned to: Nobody/Anonymous (nobody) >Summary: Problem comparing Java objects Initial Comment: The result of the comparison of Java object in Jython is a random number !!! Consider the following code: ----------- from java.lang import Integer for i in xrange(0,100): i52=Integer(52) i128=Integer(128) print i52<i128 ----------- It prints out: 1 1 0 1 ... This is definitly not a good behavior. I found a workaround by putting the following at the beginning of my code: java.lang.Object.__lt__=lambda x,y: x.compareTo(y)<0 java.lang.Object.__le__=lambda x,y: x.compareTo(y)<=0 java.lang.Object.__eq__=lambda x,y: x.compareTo(y)==0 java.lang.Object.__ne__=lambda x,y: x.compareTo(y)!=0 java.lang.Object.__gt__=lambda x,y: x.compareTo(y)>0 java.lang.Object.__ge__=lambda x,y: x.compareTo(y)>=0 java.lang.Object.__cmp__=lambda x,y: x.compareTo(y) I guess this could be fixed inside the org.python.core classes, but I could not find where the comparison takes place. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=112867&aid=761177&group_id=12867 |