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

John Griffith john.griffith at solidfire.com
Thu Jan 31 05:42:20 UTC 2013

On Wed, Jan 30, 2013 at 10:36 PM, Zhongyue Luo <zhongyue.nah at intel.com>wrote:

> 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?
> --
> 880 Zixing Road, Zizhu Science Park, Minhang District, Shanghai, 200241,
> China
> +862161166500
> _______________________________________________
> OpenStack-dev mailing list
> OpenStack-dev at lists.openstack.org
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
Personally I'm a fan of consistency for things such as this and IMO "if x
not in y" is correct.  I'm fine with adding it to hacking in Cinder at any

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20130130/2500e968/attachment.html>

More information about the OpenStack-dev mailing list