I found an error in my program in the line where I tested the existence of an object in the list of objects. The line always returned False, which meant that the object was not in the list. In fact, this went on even when I did the following:
class myObject(object): __slots__=('mySlot') def __init__(self,myArgument): self.mySlot=myArgument print(myObject(0)==myObject(0))
I used to use deepcopy, but I'm not experienced enough for Python to know when this is never needed, or mechanically, what is the difference. I also heard about pickling, but never used it. Can someone explain to me what is going on here?
Oh and one more thing. Line
if x in myIterable:
probably checking the equality between x and each element in myIterable, right? Therefore, if I can change the perceived equality between two objects, can I change the output of this line? Is there any built-in for this and all other built-in operators?
source share