|
Re: Overloading !=: msg#00030lang.jython.user
[ A Bewes ] > I've implemented __eq__() and __not__(): > so how come I can't evaluate != operator in Jython? > > public class CurveData > { > <...> > public CurveData __eq__(Object obj) > { > return MathsAPI.eq(this,obj); > } > public CurveData __not__() > { > return MathsAPI.not(this); > } > } Hello Ant, IMHO __not__() is not a special method, i suggest implementing __ne__() instead. Please find below some methods of an interface I use to implement for java classes participating in rich comparisons. /** <code><</code> */ public boolean __lt__( Object other ); /** <code><=</code> */ public boolean __le__( Object other ); /** <code>></code> */ public boolean __gt__( Object other ); /** <code>>=</code> */ public boolean __ge__( Object other ); /** <code>==</code> */ public boolean __eq__( Object other ); /** <code>!=</code> */ public boolean __ne__( Object other ); You might also want to implement __nonzero__(). JythonEssentials, around page 100, gives you more information about special methods. A little warning: not all special methods implemented by java classes are called by Jython (see the thread starting here http://aspn.activestate.com/ASPN/Mail/Message/Jython-dev/1415861 for a discussion). Best wishes, Oti. __________________________________________________ Do you Yahoo!? Yahoo! Shopping - Send Flowers for Valentine's Day http://shopping.yahoo.com ------------------------------------------------------- This SF.NET email is sponsored by: FREE SSL Guide from Thawte are you planning your Web Server Security? Click here to get a FREE Thawte SSL guide and find the answers to all your SSL security issues. http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0026en
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | PythonInterpreter and Python 11, Michel Pelletier |
|---|---|
| Next by Date: | RE: Overloading !=, A Bewes |
| Previous by Thread: | Overloading !=, A Bewes |
| Next by Thread: | RE: Overloading !=, A Bewes |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |