In defence of 80-char lines

Tim Chase python.list at tim.thechases.com
Thu Apr 4 07:09:13 EDT 2013


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",
     )

which makes diffs cleaner when you need to insert something after
faceName:

--- peter1.txt  2013-04-04 06:03:01.420762566 -0500
+++ peter2.txt  2013-04-04 06:03:34.736762582 -0500
@@ -3,4 +3,5 @@
     style=wx.DEFAULT,
     family=wx.NORMAL,
     weight=wx.BOLD,
-    faceName="FreeSans")
+    faceName="FreeSans",
+    otherValue=42)

vs.

--- tkc1.txt    2013-04-04 06:02:52.436762562 -0500
+++ tkc2.txt    2013-04-04 06:03:51.392762588 -0500
@@ -4,4 +4,5 @@
     family=wx.NORMAL,
     weight=wx.BOLD,
     faceName="FreeSans",
+    otherValue=42,
     )

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

-tkc





More information about the Python-list mailing list