[MERGE] remove has_key() usage

Robert Collins robertc at robertcollins.net
Wed Aug 30 05:27:54 BST 2006


On Tue, 2006-08-29 at 19:27 -0700, Robey Pointer wrote:
> 
> I just found out this week: "has_key" has been deprecated for a  
> while, in favor of the "x in y" syntax.  Although it's too early to  
> be very concerned about it, has_key() will also be gone in python 3.0.
> 
> My main motivation was just to update the code style to what is  
> considered "modern" python.  I'll admit to also finding "x in y"
> more  
> readable than "y.has_key(x)".
> 
> In the branch, I also fixed the 'return' statements, to use explicit  
> parens.
> 
> I may try the same thing with replacing hasattr(), unless this kind  
> of janitorial work is annoying people. 

Its good work, keep it up :).

I like foo in bar over bar.has_key(foo) myself. As for hasattr, we
should have no instances of it in the codebase, preferring
three-value-getattr.

Cheers,
Rob
-- 
GPG key available at: <http://www.robertcollins.net/keys.txt>.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060830/7862c0ee/attachment.pgp 


More information about the bazaar mailing list