Prefer "is not" over "not ... is". Closes 21540.
This commit is contained in:
parent
e56459fa23
commit
58cc81fc33
12
pep-0008.txt
12
pep-0008.txt
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue