Message857
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.
|
|
Date |
User |
Action |
Args |
2008-02-20 17:17:15 | admin | link | issue761177 messages |
2008-02-20 17:17:15 | admin | create | |
|