[openstack-dev] "if X not in Y" vs. "if not X in Y" consensus?

Zhongyue Luo zhongyue.nah at intel.com
Thu Jan 31 05:36:45 UTC 2013


Hi, all

After submitting a patch to fix some "if not X in Y" to "if X not in Y", I
got advice from someone that we should first ask everyone about their
preference between "if X not in Y" and "if not X in Y".

I have many reasons why we should use "if X not in Y", but lets first look
at some statistics.

In the ten major project of OpenStack (oslo, nova, glance, keystone,
quantum, cinder, swift, horizon, ceilometer, tempest - personal thought),
the occurrence of "if X not in Y" is 560 compared to the 152 of "if not X
in Y".

https://etherpad.openstack.org/notin

So I guess it is fair to say that the implied consensus of how to evaluate
an element in a iterable is "if X not in Y".

What I'm suggesting is that we should add an entry in HACKING.rst stating
we should use "if X not in Y" and prevent mix use of the two.

Would there be any reason why we shouldn't do this? such as it adds more
burden to reviewers, or because we should have the freedom to choose
whatever we want to use?

-- 
*Intel SSG/SSD/SOTC/PRC/CITT*
880 Zixing Road, Zizhu Science Park, Minhang District, Shanghai, 200241,
China
+862161166500
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20130131/c71c31cf/attachment.html>


More information about the OpenStack-dev mailing list