News for hackers. Stuff that matters.
Re:Python overtakes JavaScript as most questioned language o... by PopeDotNinja on Saturday April 20, 2019 @09:49AM (#19706511)
Python probably has a set type, but a common general use case for use an associative array as a key is when making a set.

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.

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"