(no title)
polyrand | 2 months ago
from types import MappingProxyType
d = {}
d["a"] = 1
d["b"] = 2
print(d)
frozen = MappingProxyType(d)
print(frozen["a"])
# Error:
frozen["b"] = "new"
[0]: https://docs.python.org/3/library/types.html#types.MappingPr...
zahlman|2 months ago
Only if you deny access to the underlying real dict.
ali_m|2 months ago