I was wondering: would it be possible to access dict values with uncomplete keys (as long as there are not more than one entry for a given string)? For example:
not the best solution, can be improved (overide getitem)
class mydict(dict):
def __getitem__(self, value):
keys = [k for k in self.keys() if value in k]
key = keys[0] if keys else None
return self.get(key)
my_dict = mydict({'name': 'Klauss', 'age': 26, 'Date of birth': '15th july'})
print(my_dict['Date'])# returns 15th july