Pythonic way for missing dict keys

Zentrader zentraders at gmail.com
Sat Jul 21 14:07:23 EDT 2007


On Jul 21, 7:48 am, Duncan Booth <duncan.bo... at invalid.invalid> wrote:
> "Rustom Mody" <rustompm... at gmail.com> wrote:
> > Can someone who knows about python internals throw some light on why
> >>>> x in dic
> > is cheaper than
> >>>> dic.has_key(x)
>
> > ??
>

>From the 2.6 PEP #361 (looks like dict.has_key is deprecated)
Python 3.0 compatability: ['compatibility'-->someone should use a
spell-checker for 'official' releases]
        - warnings were added for the following builtins which no
longer exist in 3.0:
             apply, callable, coerce, dict.has_key, execfile, reduce,
reload




More information about the Python-list mailing list