[MERGE] remove has_key() usage

Martin Pool mbp at canonical.com
Fri Sep 8 03:56:08 BST 2006


On  7 Sep 2006, Robey Pointer <robey at lag.net> wrote:
> >None is a singleton, and "is" is faster than '=='.
> 
> Mine too.  That's how I've usually done it in the past.
> 
> But recently, pychecker started complaining about me using 'is'.  It  
> says:
> 
> 	Using is None, may not always work
> 
> So what's that all about?  "May not always work"?  That sounds pretty  
> serious.  Anyone know?

It's a dumb bug in pychecker.  I'm told there will be a fix but it's not
released yet.

The general rule is that 'is' to a constant is dangerous, e.g. 

  name is 'martin'

may break if Python's rules for interning strings change.  However,
there is by definition only one None, so 'is' is safe.  We should use
'is None', and grep out the pychecker warnings.

We recently added Makefile targets to run pyflakes, which gives other
useful warnings, though I think not a strict superset of pychecker.

-- 
Martin




More information about the bazaar mailing list