About "Object in list" expression

Discussion in 'Python' started by Mirons, Nov 2, 2009.

  1. Mirons

    Mirons Guest

    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)?
     
    Mirons, Nov 2, 2009
    #1
    1. Advertising

  2. Mirons

    Jon Clements Guest

    On Nov 2, 10:41 am, Mirons <> wrote:
    > 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...
     
    Jon Clements, Nov 2, 2009
    #2
    1. Advertising

  3. Mirons

    Mirons Guest

    On 2 Nov, 11:46, Jon Clements <> wrote:
    > On Nov 2, 10:41 am, Mirons <> wrote:
    >
    > > 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...


    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.
     
    Mirons, Nov 2, 2009
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. VSK
    Replies:
    2
    Views:
    2,303
  2. =?iso-8859-1?B?bW9vcJk=?=

    Matching abitrary expression in a regular expression

    =?iso-8859-1?B?bW9vcJk=?=, Dec 1, 2005, in forum: Java
    Replies:
    8
    Views:
    851
    Alan Moore
    Dec 2, 2005
  3. GIMME
    Replies:
    3
    Views:
    11,971
    vforvikash
    Dec 29, 2008
  4. snacktime
    Replies:
    13
    Views:
    567
    Dan Sommers
    Feb 22, 2005
  5. Jason luo
    Replies:
    3
    Views:
    546
    Peter Ammon
    Aug 19, 2004
Loading...

Share This Page