Identity dictionnary

From: Jean-Sebastien Roy (js_at_jeannot.org)
Date: 02/29/04


Date: Sun, 29 Feb 2004 03:05:48 +0100

Hi !

I'm trying to create an object to be used as a key in a dictionary,
where comparison (for key retrieval) would be done by 'is' instead of
__eq__.
(__eq__ is defined in this object, but serve another purpose and does
not return a boolean).

Is defining __hash__ as id(self) sufficient to guarantee that __eq__
will never be called by the dict implementation ? (it seems to work in
practice)
If not, how to ensure __eq__ will never be called ?

Thank you very much in advance !

Regards,

js



Relevant Pages

  • Re: General Question On Handling of Function results.t
    ... might confuse another programmer working new on the project, ... > Best Regards ... >> use exception handling if you do not see anny other way, ... but a simple boolean is not enough. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Delphi type events in C#
    ... Beste Grüsse / Best regards / Votre bien devoue ... procedure TMyNewEvent (Sender: TObject; MyStream: TStream; var MyFlag: boolean) Of Object; ... procedure DoMyEvent(Sender: TObject; AStream: TStream; var AFlag: boolean); ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: "with" Coders are Monsters
    ... class function TfrmSomeForm.ClassExecute: Boolean; ... Regards, ... that chaps my butt more than anything. ...
    (borland.public.delphi.non-technical)
  • Re: General Question On Handling of Function results.
    ... Best Regards ... i create a structure with the required info and ... > use exception handling if you do not see anny other way, ... but a simple boolean is not enough. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: SUMPRODUCT is making me mad!
    ... The double negation is not needed here since the addition operator coerces ... Boolean to numeric ... > Frank Kabel ...
    (microsoft.public.excel.worksheet.functions)