In defence of 80-char lines

Roy Smith roy at panix.com
Thu Apr 4 07:52:38 EDT 2013


In article <c338b844-e9ce-46a7-9daf-20374372390e at googlegroups.com>,
 llanitedave <llanitedave at veawb.coop> wrote:
 
> I would hate to have to break up this line, for instance:
> 
> self.mainLabel.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.BOLD, faceName = 
> "FreeSans"))

I would write that as some variation on

self.mainLabel.SetFont(wx.Font(12,
                               wx.DEFAULT,
                               wx.NORMAL,
                               wx.BOLD, 
                               faceName="FreeSans"))

This lets the reader see at a glance that all the arguments go with 
wx.Font(), not with SetFont(), without having to visually parse and 
match parenthesis levels.

Actually, I would probably break it up further as:

my_font = wx.Font(12,
                  wx.DEFAULT,
                  wx.NORMAL,
                  wx.BOLD,
                  faceName="FreeSans")
self.mainLabel.SetFont(my_font)

The last thing on my mind when deciding how to format this is whether I 
would be able to punch it onto a single card.



More information about the Python-list mailing list