From: dperez <cra...@ya...> - 2007-08-29 08:02:55
|
Hi, If I run this code from the Jython 2.2 interactive console : 'a'.__cmp__('b') this is what happens: AttributeError: 'string' object has no attribute '__cmp__' This used to work in Jython 2.1. I don't understand what this happens, as the PyString class does have this method: __cmp__() Is this a bug? Regards, David -- View this message in context: http://www.nabble.com/AttributeError%3A-%27string%27-object-has-no-attribute-%27__cmp__%27-tf4346266.html#a12382403 Sent from the jython-users mailing list archive at Nabble.com. |
From: dperez <cra...@ya...> - 2007-08-29 08:24:51
|
Solved! Here is the patch I have created: http://sourceforge.net/tracker/index.php?func=detail&aid=1783844&group_id=12867&atid=312867 dperez wrote: > > Hi, > > If I run this code from the Jython 2.2 interactive console : > 'a'.__cmp__('b') > this is what happens: > AttributeError: 'string' object has no attribute '__cmp__' > > This used to work in Jython 2.1. > > I don't understand what this happens, as the PyString class does have this > method: __cmp__() > > Is this a bug? > > Regards, > David > -- View this message in context: http://www.nabble.com/AttributeError%3A-%27string%27-object-has-no-attribute-%27__cmp__%27-tf4346266.html#a12382732 Sent from the jython-users mailing list archive at Nabble.com. |
From: Charlie G. <cha...@gm...> - 2007-08-30 07:16:26
|
On 8/29/07, dperez <cra...@ya...> wrote: > If I run this code from the Jython 2.2 interactive console : > 'a'.__cmp__('b') > this is what happens: > AttributeError: 'string' object has no attribute '__cmp__' > > This used to work in Jython 2.1. > > I don't understand what this happens, as the PyString class does have this > method: __cmp__() > > Is this a bug? Nope. Python added rich comparison methods(__eq__, __gt__, __le__ and so on) in 2.1, and Jython's str uses those in 2.2 instead of __cmp__. CPython exhibits the same behavior. You can get equivalent functionality to __cmp__ with the builtin cmp function: cmp('a', 'b') Charlie |
From: dperez <cra...@ya...> - 2007-08-30 10:24:32
|
Thanks Charlie cmp() works ok. :-) Charlie Groves wrote: > > Nope. Python added rich comparison methods(__eq__, __gt__, __le__ and > so on) in 2.1, and Jython's str uses those in 2.2 instead of __cmp__. > CPython exhibits the same behavior. You can get equivalent > functionality to __cmp__ with the builtin cmp function: cmp('a', 'b') > -- View this message in context: http://www.nabble.com/AttributeError%3A-%27string%27-object-has-no-attribute-%27__cmp__%27-tf4346266.html#a12404384 Sent from the jython-users mailing list archive at Nabble.com. |