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

Terry Reedy tjreedy at udel.edu
Thu Oct 30 13:49:39 EDT 2008


D'Arcy J.M. Cain wrote:
> 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.  :-)

http://bugs.python.org/issue4243




More information about the Python-list mailing list