Duncan Gibson wrote: > We've been programming in Python for about a year. Initially we had a > lot of tests of the form > > if x == None: > do_something() > > but then someone thought that we should really change these to > > if x is None: > do_something() > > However. if you run pychecker on these two snippets of code, it > complains about the second, and not the first: > > x.py:6: Using is None, may not always work > > So the question is, which one should we really be using? > If it is the second, how do I get pychecker to shut up?
Searching comp.lang.python for 'pychecker "is None"' finds this discussion: http://groups.google.com/group/comp.lang.python/browse_frm/thread/a289d565a40fa435/9afaeb22763aadff?q=pychecker+%22is+None%22&rnum=1&hl=en#9afaeb22763aadff which says that pychecker is confused by the comparison to a constant and you should ignore it. There is a pychecker test (test_input\test90.py and test_output\test90) which shows pychecker ignoring 'is not None' so I think this is a pychecker bug in Python 2.4. It is in the bug tracker here: https://sourceforge.net/tracker/?group_id=24686&atid=382217&func=detail&aid=1227538 The bug references PEP 290 which clearly says that 'is None' is the preferred test: http://www.python.org/peps/pep-0290.html#testing-for-none I don't see a way to turn off this test but I haven't looked in detail at the config options. Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor