difference between `x in list` and `list.index(x)` for instances of a new-style class
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Sun Dec 30 08:55:49 EST 2007
More information about the Python-list mailing list
Sun Dec 30 08:55:49 EST 2007
- Previous message (by thread): do i need to create new rgbimage class
- Next message (by thread): difference between `x in list` and `list.index(x)` for instances of a new-style class
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 30 dic, 06:24, Riccardo Murri <riccardo.mu... at gmail.com> wrote: > bpgbai... at gmail.com writes: > > >> (Pydb) p graph == self.base[27] > >> True > >> (Pydb) p graph in self.base > >> True > >> (Pydb) self.base.index(graph) > >> *** ValueError: list.index(x): x not in list > > Looking at the source for both methods, they only > > use the __eq__ operator, but there is a slight difference: while one > > evaluates list[i]==x, the other reverses the operands. If your __eq__ > > is not reflexive, that could explain the difference. > > That was indeed the reason: a bug in Graph.__eq__ broke reflexivity in > certain cases. Combined with some other WTF bugs I've found at work, lately I feel more like a detective than a software developer :) -- Gabriel Genellina
- Previous message (by thread): do i need to create new rgbimage class
- Next message (by thread): difference between `x in list` and `list.index(x)` for instances of a new-style class
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list