About "Object in list" expression

M

Mirons

Hi everybody! I'm having a very annoying problem with Python: I need
to check if a (mutable) object is part of a list but the usual
expression return True also if the object isn't there. I've
implemented both __hash__ and __eq__, but still no result. what does
"in" implementation use for comparison (Python is 2.6)?
 
J

Jon Clements

Hi everybody! I'm having a very annoying problem with Python: I need
to check if a (mutable) object is part of a list but the usual
expression return True also if the object isn't there. I've
implemented both __hash__ and __eq__, but still no result. what does
"in" implementation use for comparison (Python is 2.6)?

It would help showing an example...
 
M

Mirons

It would help showing an example...

I just solved the problem! (Sorry for the bother). It was a matter of
inplementation. It's __eq__ that is called for checking instances in
list but I had implemented two version of __eq__ in different parts of
code and the interpreter chose the wrong one. Excuse me again for the
bother.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top