Pedro Werneck <[EMAIL PROTECTED]> wrote:
> On Wed, 09 Aug 2006 16:51:23 GMT
> "David Isaac" <[EMAIL PROTECTED]> wrote:
>
> > Looking forward:
> > Can I count on this independence of __getitem__ and __contains__?
> > I would like to understand whether it will be safe to count on this
> > behavior.
Bruno Desthuilliers <[EMAIL PROTECTED]> wrote:
> David Isaac wrote:
> >> 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 Desthuilli
David Isaac wrote:
>> 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" <[EMAIL PROTECTED]> wrote:
>> Well, actually it may be impo
On Wed, 09 Aug 2006 16:51:23 GMT
"David Isaac" <[EMAIL PROTECTED]> wrote:
> Looking forward:
> Can I count on this independence of __getitem__ and __contains__?
> I would like to understand whether it will be safe to count on this
> behavior.
With the builtin 'dict' implementation, dict.__contai
> 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" <[EMAIL PROTECTED]> wrote:
> Well, actually it may be important... What's so wrong wi
That's a vague question, so the obligatory "it depends" response
applies here.
If you want to guard against the unexpected, perhaps it's a good idea
to write unit tests rather than to take someone's word that it *should*
work okay every time, in every case, no matter what you're doing with
the dat
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 ?
--
http:/
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.)
I was delighted to find that __contains__ still works as before
after overriding __getitem__.So even though instance['key']
does not ra