En Fri, 09 Mar 2007 17:15:44 -0300, Paulo da Silva <[EMAIL PROTECTED]> escribió:
> What is the best way to have something like the bisect_left > method on a list of lists being the comparision based on an > specified arbitrary i_th element of each list element? > > Is there, for lists, something equivalent to the __cmp__ function for > classes? lists *are* classes (at least since Python 2.2) Inherit from the builtin list, redefine __cmp__(self, other) as cmp(self[i_th], other[i_th]) and then redefine all the rich comparison methods (__eq__, __lt__, etc) using __cmp__, e.g. __le__(self, other) as __cmp__(self, other)<=0 etc. See http://docs.python.org/ref/customization.html -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list