Python Forum
an object like a dictionary except ... - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: General (https://python-forum.io/forum-1.html)
+--- Forum: News and Discussions (https://python-forum.io/forum-31.html)
+--- Thread: an object like a dictionary except ... (/thread-39496.html)



an object like a dictionary except ... - Skaperen - Feb-27-2023

is it possible to create an object that works like a dict (e.g. can be indexed by any hashable key) but an internal method is called for fetching and storing values which gets the key and the value to store and returns the value that results from fetching?


RE: an object like a dictionary except ... - Gribouillis - Feb-27-2023

Sure, you could implement the abstract methods of collections.abc.MutableMapping.