Matt Nordhoff <[EMAIL PROTECTED]> 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 k
Gary Herron wrote:
> You could use ImmutableSets as indexes. (In fact this is the whole
> reason for the existence of ImmutableSets.)
>
> You could derive your own dictionary type from the builtin dictionary
> type, and map an index operation d[(x,y)] to
> d[ImmutableSet(a,b)]. Then all of d[a,b
Magdoll wrote:
> Is there a cleaner way to do this example:
>
> d = {('a','b'): 10, ('a','c'): 20, ('b','c'): 30}
>
> The key is always a pair (x,y), but d[(x,y)] should have the same
> result as d[(y,x)]. So either I would have to store both d[(x,y)] and
> d[(y,x)] (unncessary extra space?), or wr
On Sat, 09 Feb 2008 13:51:34 -0800, Magdoll wrote:
> Is there a cleaner way to do this example:
>
> d = {('a','b'): 10, ('a','c'): 20, ('b','c'): 30}
>
> The key is always a pair (x,y), but d[(x,y)] should have the same result
> as d[(y,x)]. So either I would have to store both d[(x,y)] and d[(y