"xxx.has_key(a)" vs "a in xxx"

D'Arcy J.M. Cain darcy at druid.net
Thu Oct 30 11:11:07 EDT 2008


On Thu, 30 Oct 2008 09:50:57 -0500
"Kurt Smith" <kwmsmith at gmail.com> wrote:
> > 2.5 docs say that:
> >  "a.has_key(k) Equivalent to k in a, use that form in new code"
> 
> Meaning: don't use 'a.has_key(k)'.
> 
> > 2.6 docs say that:
> >  "dict.has_key(key) is equivalent to key in d, but deprecated."
> 
> Meaning, 'd.has_key(key)' is deprecated -- use 'key in d'.

Wow!  That is so badly written.  Both those statements could easily be
read the opposite by someone reading the docs.  Granted the latter is
better and it is correct but it could be clearer the the user.  It
should be something like;

  """dict.has_key(key) is deprecated.  Use "key in dict" instead."""

IOW your explanation of the sentence is better than the sentence.  :-)

-- 
D'Arcy J.M. Cain <darcy at druid.net>         |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.



More information about the Python-list mailing list