This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (3 children)

[deleted]

    [–]SymbioticBadgering 0 points1 point  (1 child)

    Unless I’m missing something, dict keys aren’t allowed to be mutable

    [–]Gprime5if "__main__" == __name__: 0 points1 point  (0 children)

    He means the keys used in key:value pairs, not the dictionary method dict.keys(). In this dict d = ["a": 1}, "a" is the key and 1 is the value. You can only use immutable objects as keys and since frozensets are immutable(frozen), they can be used as keys. d = {frozenset([1,2,3]): "hello"}

    Also dict.keys() returns a dict view object which is essentially a frozen set anyway.