I was wondering if there is an easy way to essentially have multiple keys in a dictionary for one value. An example of what I would like to achieve is as following:
class test:
key="test_key"
def __str__(self):
return self.key
tester = test()
dictionary = {}
dictionary[tester] = 1
print(dictionary[tester])
print(dictionary["test_key"])
where the output would be:
>>> 1
>>> 1
What I'm looking for is a way to automatically convert the object to a string before its used as a key. Is this possible?