From 5674da98b1ce854e6589c03be5c5f911537b4688 Mon Sep 17 00:00:00 2001 From: Zhongyue Luo Date: Mon, 4 Feb 2013 10:20:41 +0800 Subject: [PATCH] Update HACKING.rst per recent changes Added "is not" usage with examples Fixed "not in" usage description * https://review.openstack.org/#/c/20877/ Change-Id: I89fbc62a8b31bc7ef750cc1e80f73b9c1e366fd3 --- HACKING.rst | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/HACKING.rst b/HACKING.rst index afd861c84f..1a064e9456 100644 --- a/HACKING.rst +++ b/HACKING.rst @@ -13,15 +13,23 @@ General - Do not write "except:", use "except Exception:" at the very least - Include your name with TODOs as in "#TODO(termie)" - Do not name anything the same name as a built-in or reserved word -- Use the "not in" operator for collection membership evaluation. Example:: +- Use the "is not" operator when testing for unequal identities. Example:: - if not X in Y: # BAD, hard to understand + 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 is Z): # OKAY, still better than all those 'not's + if not (X in Y or X in Z): # OKAY, still better than all those 'not's pass