In defence of 80-char lines

Joshua Landau joshua.landau.ws at gmail.com
Thu Apr 4 13:18:00 EDT 2013


On 4 April 2013 12:09, Tim Chase <python.list at tim.thechases.com> wrote:

> On 2013-04-04 08:43, Peter Otten wrote:
> > llanitedave wrote:
> >> self.mainLabel.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.BOLD,
> faceName = "FreeSans"))
> >
> > I think I would prefer
> >
> > labelfont = wx.Font(
> >     pointSize=12,
> >     style=wx.DEFAULT,
> >     family=wx.NORMAL,
> >     weight=wx.BOLD,
> >     faceName="FreeSans")
> > self.mainLabel.SetFont(labelfont)
>
> +1
> The only change I'd make to this suggestion would be to add a
> semi-superfluous comma+newline after the last keyword argument too:
>
>  labelfont = wx.Font(
>      pointSize=12,
>      style=wx.DEFAULT,
>      family=wx.NORMAL,
>      weight=wx.BOLD,
>      faceName="FreeSans",
>      )
>

Since we're all showing opinions, I've always prefered the typical block
indentation:

labelfont = wx.Font(
    pointSize=12,
    style=wx.DEFAULT,
    family=wx.NORMAL,
    weight=wx.BOLD,
    faceName="FreeSans",
) # Not indented here

as

A(
    B(
        C,
        D,
        E,
    )
)

reads a lot cleaner than

A(
    B(
        C,
        D,
        E
        )
    )

which makes diffs cleaner when you need to insert something after
> faceName:
>
<DIFS SNIP>

That is a very good point :).

Additionally, if there are lots of keyword parameters like this, I'd
> be tempted to keep them in sorted order for ease of tracking them
> down (though CSS has long-standing arguments on how properties should
> be ordered, so to each their own on this).
>

Personally I'd rarely be tempted to put more than 9 or so arguments
directly into a function or class. Most of the time I can imagine unpacking
(or equiv.) would look much more readable in the circumstances that apply.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130404/bc22d461/attachment.html>


More information about the Python-list mailing list