__peter__ at web.de
Tue Jan 6 10:14:58 CET 2004
Thomas Guettler wrote:
> I want to unique a list of tuples. Since
> __hash__ returns a 32 bit integer, there
> could be a situtation where two different tupples
> return the same value.
Maybe you can decorate/uniquify/undecorate?
>>> items = [t1, t2, t1, t1]
>>> di = [(id(i), i) for i in items]
>>> from sets import Set
>>> si = Set(di)
>>> ui = [i for i in si]
[(1, 2, 3), (1, 2, 3)]
> Is there a dictionary type which uses __cmp__() like
> btrees in the standard library?
I don't understand. For the above example an algorithm based on __cmp__()
would return a list with a single item which does not seem to be what you
More information about the Python-list