Does Python3 offer a FrozenDict?

Johannes Bauer dfnsonfsduifb at gmx.de
Tue Dec 16 23:50:50 EST 2008


Steven D'Aprano schrieb:
> 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.

Well, I'd like to access it like a dict afterwards, e.g.

for (i, j) in foo.items():
	print(i["a"])

Regards,
Johannes

-- 
"Meine Gegenklage gegen dich lautet dann auf bewusste Verlogenheit,
verlästerung von Gott, Bibel und mir und bewusster Blasphemie."
         -- Prophet und Visionär Hans Joss aka HJP in de.sci.physik
                         <48d8bf1d$0$7510$5402220f at news.sunrise.ch>



More information about the Python-list mailing list