Re:Python overtakes JavaScript as most questioned language o...
by Scarblac on Saturday April 20, 2019 @11:49AM
(#19707157)
Yes, Python has both a set type and the immutable "frozenset" type, that can be used as a dictionary key.
someset = {"one", "two", "three"}
"one" in someset # true
frozen = frozenset(someset)
somedict = {frozen: "example"}
frozen in somedict # true somedict[frozen] # "example"
dict = { "foo" : "bar" }
set = { dict : true }
set.has_key?(dict) # true
I'm sure there are other use cases where dict keys can be convenient.