> I have seen at several places "x == None" and "x is None" within
> if-statements.
> What is the difference? 
> Which term should I prefer and why?
> 
> 
> -- 
> Ullrich Horlacher              Server und Virtualisierung
> Rechenzentrum IZUS/TIK         E-Mail: horlac...@tik.uni-stuttgart.de
> Universitaet Stuttgart         Tel:    ++49-711-68565868
> Allmandring 30a                Fax:    ++49-711-682357
> 70550 Stuttgart (Germany)      WWW:    http://www.tik.uni-stuttgart.de/

In this case, the Style Guide for Python Code [1] recommends use "is or is not, 
never the equality operators" [2].

If you use the pep8 tool [3] to check your code, the error code that will be 
raised is E711 [4].

[1] https://www.python.org/dev/peps/pep-0008/
[2] https://www.python.org/dev/peps/pep-0008/#programming-recommendations
[3] http://pep8.readthedocs.org/en/latest/intro.html
[4] http://pep8.readthedocs.org/en/latest/intro.html#error-codes
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to