__contains__ vs. __getitem__

David Isaac aisaac0 at verizon.net
Wed Aug 9 14:56:18 EDT 2006


> Alan 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.)

"Bruno Desthuilliers" <onurb at xiludom.gro> wrote:
> Well, actually it may be important... What's so wrong with d.get('key')
> that you need this behaviour ?

I want to use the mapping with string interpolation.

Alan Isaac





More information about the Python-list mailing list