My class' xor function is working as intended but when doing a^=b, I get 'TypeError: unsupported operand type(s) for ^=: 'NoneType' and 'Multiset.'' Relevant code below:
def __xor__(self,o):
d=Multiset() #subclass of dict
for x in self|o: #for each item in both multisets
m=abs((self[x] if x in self else 0) - (o[x] if x in o else 0)) #determines absolute difference of multiplicities of each element
if m>0:
d.add(x,m) #adds item x with multiplicity m to d
return d
def __ixor__(self,o):
self=self^o
I have confirmed that a^b returns a Multiset and that setting a=a^b does not throw an error. I have tried commenting out the ixor definition as well as rewriting it as follows:
def __ixor__(self,o):
buffer=self^o
self=buffer
At this point, I'm just about out of ideas of what the problem could be.