[Python-ideas] PEP8 operator must come before line break

Bruce Leban bruce at leban.us
Thu Apr 14 15:10:08 EDT 2016


I find the operator at the beginning of the line much more clear in code
like this:

innerWidth = (outerWidth
              - 2 * border_width
              - left_margin
              - right_margin)

outerHeight  = (innerHeight
                + (title_height if have_title else 0)
                + (subtitle_height if have_subtitle else 0)
                - (1 if have_title and have_subtitle else 0))

outerHeight  = (innerHeight
                + (title_height
                   if have_title
                   else 0)
                + (subtitle_height
                   if have_subtitle
                   else 0)
                - (1
                   if have_title and have_subtitle
                   else 0))

area = ((multiline_calculation_of_height)
        * (multiline_calculation_of_width))

The first two are taken and sanitized from real code.

--- Bruce
Check out my puzzle book and get it free here:
http://J.mp/ingToConclusionsFree (available on iOS)



On Thu, Apr 14, 2016 at 11:48 AM, SW <walker_s at hotmail.co.uk> wrote:

> That'll teach me for stepping away from the computer...
>
> As for changing an established rule, I agree that can be difficult. The
> reason this one became an irritation for me is that it was only in the
> last few months that I saw flake8 (my style complainer of choice) start
> complaining about this, so it's not quite so entrenched as other
> elements of style.
>
> I agree that placing the binary operator at the end shows the line
> should continue, and thus could be valid, but I also think that placing
> it at the start of the next line shows the logic flow for each part of
> the expression more clearly- as shown in the examples I originally gave.
>
> Thanks,
> S
>
> On 14/04/16 18:23, Guido van Rossum wrote:
> > Thanks, that was obviously an oversight. I've fixed the PEP.
> >
> > If the discussion ends up with rough consensus on changing this I will
> > happily change it back (and change all other occurrences to match the
> > new rule).
> >
> > Note that my request for "rough consensus" does *not* imply a vote. +1
> > and -1 votes (nor fractions in between) should not be posted --
> > however cogent arguments for/against the status quo (or for
> > relinquishing the rule altogether) are welcome.
> >
> > On Thu, Apr 14, 2016 at 10:02 AM, Matthias welp <boekewurm at gmail.com>
> wrote:
> >>> Where in PEP 8 does it violate its own advice
> >> As the OP did not reply this fast, from the webpage (/dev/peps/pep-0008)
> >>
> >> section indentation, just after 'Acceptable options in this situation
> >> include, but are not limited to: '
> >>
> >> # Add some extra indentation on the conditional continuation line.
> >> if (this_is_one_thing
> >>         and that_is_another_thing):
> >>     do_something()
> >>
> >> That is the only place I could find just now.
> >>
> >>
> >> _______________________________________________
> >> Python-ideas mailing list
> >> Python-ideas at python.org
> >> https://mail.python.org/mailman/listinfo/python-ideas
> >> Code of Conduct: http://python.org/psf/codeofconduct/
> >
> >
>
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160414/33f2aecc/attachment.html>


More information about the Python-ideas mailing list