Identity dictionnary
From: Jean-Sebastien Roy (js_at_jeannot.org)
Date: 02/29/04
- Next message: Bob Ippolito: "Re: [Tutor] Re: Reading text lines from a socket"
- Previous message: Jeff Epler: "Re: cls"
- Next in thread: Erik Max Francis: "Re: Identity dictionnary"
- Reply: Erik Max Francis: "Re: Identity dictionnary"
- Reply: Bob Ippolito: "Re: Identity dictionnary"
- Reply: Jeff Epler: "Re: Identity dictionnary"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: Bob Ippolito: "Re: [Tutor] Re: Reading text lines from a socket"
- Previous message: Jeff Epler: "Re: cls"
- Next in thread: Erik Max Francis: "Re: Identity dictionnary"
- Reply: Erik Max Francis: "Re: Identity dictionnary"
- Reply: Bob Ippolito: "Re: Identity dictionnary"
- Reply: Jeff Epler: "Re: Identity dictionnary"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|