In java, I have my client class that have the "code" attr, and the equals method. Method equals receives another client and compares with itself's code attr.
In python, I just read that we have the __cmp__
method, to do the same as java method equals. Ok, I did that. I created my class client, with "code" attr and the method comp that verify if the code is the same.
class Client():
def __init__(self, code):
self.code = code
def __cmp__(self, obj):
return obj.code == self.code
def __repr__(self):
return str(self.code)
Then I put 3 Client objects in a python's list:
bla = [Client(1), Client(2), Client(3)]
Then, when I try:
bla.remove(Client(3))
The amazing python removes the first element (the Client with code 1).
What I am doing wrong? I searched the implementation of list in python's Lib files, but is not easy to find.
Anyone can help?