A workaround for Python's missing frozen-dict type? [duplicate]
问题 This question already has answers here : Immutable dictionary in Python 3: how to make keys(), items(), and values() dictionary views immutable (2 answers) What would a “frozen dict” be? (14 answers) Closed 3 years ago . In Python, when you want to use lists as keys of some dictionary, you can turn them into tuples, which are immutable and hence are hashable. >>> a = {} >>> a[tuple(list_1)] = some_value >>> a[tuple(list_2)] = some_other_value The same happens when you want to use set objects