no more comparisons

Carl Banks pavlovevidence at gmail.com
Thu Mar 13 12:45:37 EDT 2008


On Mar 13, 12:38 pm, Alan Isaac <ais... at american.edu> wrote:
> Dan Bishop wrote:
> > def cmp_key(cmp_fn):
> >     class CmpWrapper(object):
> >         def __init__(self, obj):
> >             self.obj = obj
> >         def __cmp__(self, other):
> >             return cmp_fn(self.obj, other.obj)
> >     return CmpWrapper
>
> Apparently I'm overlooking something obvious ...
>
> how is this supposed to work if __cmp__ is no longer
>
> being called?  (Which was my understanding.)


It won't.  In Python 3.0 you'd have to write this class in terms of
rich comparisons (__lt__, __gt__, etc.).


Carl Banks



More information about the Python-list mailing list