deprecation of has_key?

Steven Bethard steven.bethard at gmail.com
Thu Apr 21 11:10:49 EDT 2005


Denis S. Otkidach wrote:
> On Thu, 21 Apr 2005 08:50:25 -0600 Steven Bethard wrote:
> 
> SB> Huh?  I'm not following your logic.  Why is "item in dict" less
> SB> readable than "dict.has_key(item)"?  Something to do with expecting
> SB> inverses that don't exist?
> SB> 
> SB> Personally, I use "item in dict" because it's quite readable to me,
> SB> and generally faster.
> 
> For me dictionary is a collection of key-value pairs, but not a
> collection of keys (that's what set is).

Ahh, ok.  Now I understand.  I think you could probably search the 
python-dev archives and see why the decision was made as it was.  For 
pretty much all my purposes, "key in dict" is much more useful than 
"item in dict".  Practicality beats Purity and all. ;)

STeVe



More information about the Python-list mailing list