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

Joe Gordon jogo at cloudscaling.com
Thu Jan 31 23:10:42 UTC 2013


On Thu, Jan 31, 2013 at 12:56 PM, Mark McLoughlin <markmc at redhat.com> wrote:

> 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.
>

Although I am on the fence about adding this to HACKING.rst ... since we
have it:  https://review.openstack.org/#/c/20950


>
> 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/20130131/abcf8205/attachment.html>


More information about the OpenStack-dev mailing list