Prefer "is not" over "not ... is". Closes 21540.

This commit is contained in:
Barry Warsaw 2014-05-20 18:14:17 -04:00
parent e56459fa23
commit 58cc81fc33
1 changed files with 12 additions and 0 deletions

View File

@ -919,6 +919,18 @@ Programming Recommendations
have a type (such as a container) that could be false in a boolean
context!
- Use ``is not`` operator rather than ``not ... is``. While both
expressions are functionally identical, the former is more readable
and preferred.
Yes::
if foo is not None:
No::
if not foo is None:
- When implementing ordering operations with rich comparisons, it is
best to implement all six operations (``__eq__``, ``__ne__``,
``__lt__``, ``__le__``, ``__gt__``, ``__ge__``) rather than relying