Unexpected behavior with dictionary keys containment and a user-defined class

2009-01-12 Thread Rob Clewley
Hi, the short version of my question is: when is a dictionary's __contains__ method behavior different to using the 'in' idiom? (because I have an example of a difference in my code). Longer version: I have a user-defined class with a few overrides of special methods, particularly __eq__ and

Re: Unexpected behavior with dictionary keys containment and a user-defined class

2009-01-12 Thread James Stroud
Rob Clewley wrote: Hi, the short version of my question is: when is a dictionary's __contains__ method behavior different to using the 'in' idiom? (because I have an example of a difference in my code). Never. Longer version: I have a user-defined class with a few overrides of special

Re: Unexpected behavior with dictionary keys containment and a user-defined class

2009-01-12 Thread Steven D'Aprano
On Mon, 12 Jan 2009 22:41:00 -0500, Rob Clewley wrote: Hi, the short version of my question is: when is a dictionary's __contains__ method behavior different to using the 'in' idiom? (because I have an example of a difference in my code). [...] i in d.keys() and d.keys()[10] == i both

Re: Unexpected behavior with dictionary keys containment and a user-defined class

2009-01-12 Thread Rob Clewley
Hi, the short version of my question is: when is a dictionary's __contains__ method behavior different to using the 'in' idiom? (because I have an example of a difference in my code). Never. Yes, sorry, I managed to summarize the long version incorrectly :) Well, the only conclusion is