[Tutor] TypeError: dict objects are unhashable

Emile van Sebille emile at fenx.com
Sat Mar 14 22:27:32 CET 2009


Mark Tolonen wrote:
>>>> [dict(n) for n in set(tuple(n.items()) for n in l1)]

Anyone know if the ordered items for two different dicts where dicta == 
dictb is guaranteed the same?  I know the ordering is unspecified but 
you can depend on the sequence of keys matching data and I think it'll 
also match items.

but for all DA's and DB's below, is that true?

 >>> a = range(52)
 >>> import string
 >>> DA = dict(zip(a,string.letters))
 >>> DB = dict(zip(a,string.letters))
 >>> DA == DB
True
 >>> DA.items() == DB.items()
True
 >>>

Emile



More information about the Tutor mailing list