[Tutor] pychecker: x is None or x == None

Duncan Gibson duncan at thermal.esa.int
Fri Aug 12 15:14:35 CEST 2005


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?

I've hunted around in the documentation, and if there is a clear
discussion about this issue, I must have missed it.

Cheers
Duncan


More information about the Tutor mailing list