Can I overload the compare (cmp()) function for a Lists ([]) index function?

xkenneth xkenneth at gmail.com
Fri Sep 28 13:36:54 EDT 2007


On Sep 28, 12:30 pm, xkenneth <xkenn... at gmail.com> wrote:
> Looking to do something similair. I'm working with alot of timestamps
> and if they're within a couple seconds I need them to be indexed and
> removed from a list.
> Is there any possible way to index with a custom cmp() function?
>
> I assume it would be something like...
>
> list.index(something,mycmp)
>
> Thanks!

or can i just say....

list.index.__cmp__ = mycmp

and do it that way? I just want to make sure I'm not doing anything
evil.




More information about the Python-list mailing list