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

Alex Meade alex.meade at rackspace.com
Mon Feb 4 20:34:53 UTC 2013


+1
 
-----Original Message-----
From: "Mark McLoughlin" <markmc at redhat.com>
Sent: Thursday, January 31, 2013 3:56pm
To: "OpenStack Development Mailing List" <openstack-dev at lists.openstack.org>
Subject: Re: [openstack-dev] "if X not in Y" vs. "if not X in Y" consensus?



On Thu, 2013-01-31 at 12:32 -0800, Maru Newby wrote:
> Hi all,
> 
> I'm the reviewer that prompted Zhongyue Luo to ask this question on
> the mailing list, and would like to chime in.
> 
> As has been noted on this thread, not only are the two forms logically
> equivalent, but they also produce the same byte code.  The only reason
> to mandate one over the other would be 'readability'.  I would
> suggest, though, that the minimal increase in so-called readability
> does not justify requiring reviewers to enforce this style rule.
> 
> That is not to say that I think code consistency is without value -
> quite the opposite.  I subscribe to Ableson/Sussman's view that
> "Programs must be written for people to read, and only incidentally
> for machines to execute." I do think, however, that the effort
> required to enforce a given rule should be weighed carefully against
> the value that its enforcement brings.  I'm not of the opinion that
> manual effort is justified in this particular case.  If the community
> consensus is that this rule needs to be enforced, I suggest that it be
> done through automatic detection (ala pep8), or even automatic
> correction (ala the kinds of code reformatting tools that are
> pervasive in c/c++ land).

How about this as a conclusion?

We generally prefer "X not in Y", but few think it's a big deal.

Reviewers don't need to enforce this, but they shouldn't be recommending
"not X in Y" either.

If anyone feels like taking on the janitorial task of removing uses of
"not X in Y" from code occasionally, that's totally cool.

If someone wants to write a hacking.py check for this, that's totally
cool too.

Cheers,
Mark.


_______________________________________________
OpenStack-dev mailing list
OpenStack-dev at lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20130204/9f110391/attachment.html>


More information about the OpenStack-dev mailing list