Does Python3 offer a FrozenDict?

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Wed Dec 17 02:26:58 CET 2008


On Tue, 16 Dec 2008 17:59:30 +0100, Johannes Bauer wrote:

> Hello group,
> 
> is there anything like a frozen dict in Python3, so I could do a
> 
> foo = { FrozenDict({"a" : "b"}): 3 }
> 
> or something like that?


If *all* you want is to use it as a key, then:

tuple(sorted(some_dict.items))

may do the job.



-- 
Steven



More information about the Python-list mailing list