summaryrefslogtreecommitdiffstats
path: root/HACKING.rst
diff options
context:
space:
mode:
Diffstat (limited to 'HACKING.rst')
-rw-r--r--HACKING.rst18
1 files changed, 18 insertions, 0 deletions
diff --git a/HACKING.rst b/HACKING.rst
index cf6abb39..bf0befca 100644
--- a/HACKING.rst
+++ b/HACKING.rst
@@ -18,6 +18,24 @@ General
- Do not name anything the same name as a built-in or reserved word
- When defining global constants, define them before functions and classes
- Avoid using "double quotes" where you can reasonably use 'single quotes'
+- Use the "is not" operator when testing for unequal identities. Example::
+
+ if not X is Y: # BAD, intended behavior is ambiguous
+ pass
+
+ if X is not Y: # OKAY, intuitive
+ pass
+
+- Use the "not in" operator for evaluating membership in a collection. Example::
+
+ if not X in Y: # BAD, intended behavior is ambiguous
+ pass
+
+ if X not in Y: # OKAY, intuitive
+ pass
+
+ if not (X in Y or X in Z): # OKAY, still better than all those 'not's
+ pass
TODO vs FIXME