bisect on a list of lists
steve at REMOVE.THIS.cybersource.com.au
Sat Mar 10 03:45:50 CET 2007
On Fri, 09 Mar 2007 18:57:42 -0300, Gabriel Genellina wrote:
> En Fri, 09 Mar 2007 17:15:44 -0300, Paulo da Silva
> <psdasilvaX at esotericaX.ptX> 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
> lists *are* classes (at least since Python 2.2)
Not quite. Classes and types are *almost* the same, but not exactly.
>>> class Spam:
Usually the difference doesn't make a difference, but sometimes it does.
>>> Spam.x = 3
>>> list.x = 3
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: can't set attributes of built-in/extension type 'list'
More information about the Python-list