To define a class behaviour in the following statement:
my_object[item] = ...
I know I need to define the
What method do I need to define for the following statement:
my_object[item] += ...
__getitem__ to retrieve the initial value of
__setitem__ to set the new value.
Additionally, Python needs a way to perform the addition. Either
my_object[item] needs to implement the addition with
__iadd__, or the object on the right side of the
+= needs to implement