Came across code where a class which extends Dict class and overrides the methods.
Following code snippet is what I can't understand:
class HeaderKeyDict(dict):
"""
A dict that title-cases all keys on the way in, so as to be
case-insensitive.
"""
# More methods
def __getitem__(self, key):
return dict.get(self, key.title())
def get(self, key, default=None):
return dict.get(self, key.title(), default)
# More methods
What is confusing me is what is dict.get(self, ...) doing ? Is this similar to dict.get(key) method ?
Will dict.get(self) call the self.get() method when we do [ ] on this class object ?