I understand that __add__ can be used to define the use of + for a new class. What is the equivalent for defining the use of []?
I would like to create a class Parent that contains a dictionary codes, and I would like Parent[key]to return Parent.codes[key]
I understand that I could probably just use Parent.codes[key], but this seems needlessly verbose if methods can be used to avoid similar issues with things like + and ==.
#python #methods