__eq__ on a dict

Neil Benn benn at cenix-bioscience.com
Mon Jul 11 14:22:37 CEST 2005


Steven D'Aprano wrote:

> On Mon, 11 Jul 2005 12:42:55 +0200, Neil Benn wrote:
>
>  
>
>> Hello,
>>
>>            I can't find the docs for __eq__ on a dict and I can't 
>> find a description on what the eq does (strangely it does implement > 
>> and < but I have no idea what that does).  Does anyone know 
>> (definitively) what the __eq__, __gt__, __lt__ methods do.
>>
>>    BTW, google is not my friend - I invited it out for a drink last 
>> week and it stood me up :-) .
>>   
>
>
> It works for me. Google on "__eq__ Python" and the 5th and 6th sites are:
>
> http://python.active-venture.com/ref/customization.html
> http://www.network-theory.co.uk/docs/pylang/ref_32.html
>  
>
<snip>
As previous reply

> Normally, asking Python for help is a good way to read the docs, but in
> this particular case, it is a big let-down:
>
> py> help({}.__eq__)
> Help on method-wrapper:
>
> __eq__ = <method-wrapper object>
>
>
> For any two objects x and y, when you call
> x == y
>
> <snip>
>

<snip>
That's the empirical evidence that I got but I want to be 100% sure that 
this holds in all cases - I'm wary about using empirical evidence 
leading to assumptions in my code - I take the paradigm that 'Assumption 
is the mother of all f**k-ups'.

> In general, you should not call __eq__ directly, but use the == operator
> instead.
>
>  
>
<snip>
   Yeah I'm aware of that, I didn't want to start talking about ==, etc 
or I may mislead people into the - this is what __eq__ means path of 
explanation.

Thanks for your response.

Neil

-- 

Neil Benn
Senior Automation Engineer
Cenix BioScience
BioInnovations Zentrum
Tatzberg 46
D-01307
Dresden
Germany

Tel : +49 (0)351 4173 154
e-mail : benn at cenix-bioscience.com
Cenix Website : http://www.cenix-bioscience.com




More information about the Python-list mailing list