bisect on a list of lists
Paulo da Silva
psdasilvaX at esotericaX.ptX
Fri Mar 9 19:25:24 EST 2007
Gabriel Genellina escreveu:
> En Fri, 09 Mar 2007 17:15:44 -0300, Paulo da Silva
> <psdasilvaX at esotericaX.ptX> escribió:
...
>
> lists *are* classes (at least since Python 2.2)
> Inherit from the builtin list, redefine __cmp__(self, other) as
...
Thanks Gabriel. This sounds very nice for my purpose.
I have some doubts however. How do I "transform" a list into
MyList? Is this the best way?
class MyList(list):
def __init__(self,l=None):
if l != None:
self=copy(l) (or self.extend(l) - this does not need copy module)
Then I can do something like xl=MyList([ ... ])
I read the description of __new__ but I didn't fully understand it and
didn't find any examples on how it is used.
Is it usable in this context? How?
Thanks
Paulo
More information about the Python-list
mailing list