From: D-Man <ds...@ri...> - 2001-02-24 21:22:47
|
On Sat, Feb 17, 2001 at 10:59:26AM -0800, Eli Ateljevich wrote: | Hi. I have inherited a jpython application that makes use of user-defined | java time series classes. These classes have overloaded operators that do | pretty much what you would expect. For instance, given a time series x and | a time series y, x+y returns a new time series with the elements of x and y | added at corresponding times. | | It would be very useful to be able to define x>y the same way. However, | when I write my own __cmp__ method jpython ignores it. The results from You should use jython instead of jpython. | x>y | are an arbitrary scalar value, as if I had left comparisons undefined. If I | call my method directly by name: | x.__cmp__(y) | it works fine. Any advice? | I just realized what is wrong here. x>y doesn't call __cmp__, but __gt__ instead I think it would be good to RTFM some more. Find out where __cmp__ is used (list.sort uses it) and where __gt__, __lt__, etc. are used. (I don't know, so I can't help any more than this, but the Fine Manual can ;-)) HTH, -D |