__contains__ vs. __getitem__

Bruno Desthuilliers onurb at xiludom.gro
Wed Aug 9 12:58:50 EDT 2006


David Isaac wrote:
> I have a subclass of dict where __getitem__ returns None rather than
> raising KeyError for missing keys.  (The why of that is not important for
> this question.)

Well, actually it may be important... What's so wrong with d.get('key')
that you need this behaviour ?




More information about the Python-list mailing list