You can make a minimal class using frozenset()
to store the data and then add a custom __getitem__()
method.
class Idict:
def __init__(self, d):
self.d = frozenset(d.items())
def __getitem__(self, k):
return [v for _k,v in self.d if _k == k][0]
d = {'a':1, 'b':2}
a = Idict(d)
a['a'] #1
a['h'] = 0 #TypeError: 'Idict' object does not support item assignment