different key, same value in dictionaries

Paul Rubin http
Sun Feb 10 01:50:31 CET 2008


Matt Nordhoff <mnordhoff at mattnordhoff.com> writes:
> Since Python 2.4, sets are built-in types. Use "set" and "frozenset"
> instead of "sets.Set" and "sets.ImmutableSet", respectively.
> 
> If you need Python 2.3 compatibility, you can do something like this:

As an alternative, you could canonicalize the keys by sorting them
into lexicographic order.  I.e. you'd store both (2,3) and (3,2) as
(2,3).



More information about the Python-list mailing list