I just want to use the __add__
modifier, to use '+=' to easily add to elements of a classinstance:
class Problem:
def __init__(self):
self.lItems = []
def __add__(self, other):
self.lItems.append(other)
problem = Problem()
problem += 'text'
print(problem)
The resulting problem will equal None
after the +=
. Why? And how can I prevent that from happening?
P.S.: I have also tried implementing __iadd__
with no effect...