Boilerplate in rich comparison methods

Gabriel Genellina gagsl-py at yahoo.com.ar
Sat Jan 13 21:26:21 EST 2007


"Steven D'Aprano" <steve at REMOVE.THIS.cybersource.com.au> escribió en el 
mensaje 
news:pan.2007.01.13.19.09.09.242271 at REMOVE.THIS.cybersource.com.au...
> On Fri, 12 Jan 2007 23:28:06 -0800, Paul Rubin wrote:
>
>> If it's that uniform I think you can just use __cmp__:
>
> Good point -- I had somehow picked up the mistaken idea that __cmp__ was
> depreciated in favour of rich comparisons.

If you inherit from a base class that implements rich comparisons, you have 
to override all those methods, else your __cmp__ won't be called at all.
Sometimes it may be enough to implement __cmp__ and make all others call it.

-- 
Gabriel Genellina 






More information about the Python-list mailing list