Is there a dictionary-like object that is immutable? [duplicate]
问题 This question already has answers here : What would a “frozen dict” be? (14 answers) Closed 12 days ago . I would like a Python object that can flexibly take any key and I can access by key, like a dictionary, but is immutable. One option could be to flexibly generate a namedtuple but is it bad practice to do this? In the example below a linter would not expect nt to have attribute a for example. Example: from collections import namedtuple def foo(bar): MyNamedTuple = namedtuple("MyNamedTuple