On Mar 5, 8:03 pm, [EMAIL PROTECTED] wrote: > On Mar 5, 5:31 pm, Grant Edwards <[EMAIL PROTECTED]> wrote: > > > On 2008-03-05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > Anyway, if (a,b) is a key in dictionary d, can it guarantee > > > that (b,a) is also in it, and maps to the same object? > > Er... -specialized- dictionary d. > > > To solve that problem, Python provides the immutable > > "frozenset" type: > > > >>> s1 = frozenset((1,2)) > > >>> s2 = frozenset((2,1)) > > >>> s1 == s2 > > True > > >>> d = {s1: "hi there"} > > >>> s1 in d > > True > > >>> s2 in d > > True > > Ah. Perfect. With this, I can just call frozenset on keys in > __setitem__ and __getitem__... (though at that, it may be easier > verbatim*.)
> a= SomeList( [ 1,2,3 ] ) > b= SomeList( [ 1,2,3 ] ) > assert a is not b > d[a]= True > assert b not in d > #there's the hangup *plonk* key is an iterable, just like the constructors to <bleep bl bbl bleep> other collection. >>> 2 in d Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'int' object is not iterable Interface first? In YOUR face first! -- http://mail.python.org/mailman/listinfo/python-list