trailing underscores naming convention_

Michael Torrie torriem at gmail.com
Fri May 9 12:35:09 EDT 2014


On 05/08/2014 11:49 PM, Metallicow wrote:
> I guess to be more clear here is a small code snippet that shows what
> is happening more readably. Hence the underscores question.

In a case like this I'd probably prefer to number the methods rather
than add underscores to the end of the names.  My current font, for
example, connects the underscores together, so it's a bit hard from a
glance to tell if it's just two underscores or three.

I'd prefer OnLeftDClick1, OnLeftDClick2, OnLeftDClick3, for example.

And I also prefer pep8 method names as well, on_left_dclick1, etc.  But
when the underlying library doesn't follow pep8, then I guess it does
not matter (self.Bind is from the library I presume).


> class MainAuiManager(aui.AuiManager): def __init__(self,
> managed_window=None, agwFlags=0) aui.AuiManager.__init__(self,
> managed_window, agwFlags)
> 
> ## self.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDClick) 
> self.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDClick_) 
> self.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDClick__) 
> self.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDClick___) # etc...
> 
> ## def OnLeftDClick(self, event): ##     """This will override the
> aui.AuiManager.OnLeftDClick event method.""" ##     event.Skip() ##
> print('OnLeftDClick')
> 
> def OnLeftDClick_(self, event): """This will extend the
> aui.AuiManager.OnLeftDClick event method.""" event.Skip() 
> print('OnLeftDClick_')
> 
> def OnLeftDClick__(self, event): """This will extend the
> aui.AuiManager.OnLeftDClick event method.""" event.Skip() 
> print('OnLeftDClick__')
> 
> def OnLeftDClick___(self, event): """This will extend the
> aui.AuiManager.OnLeftDClick event method.""" event.Skip() 
> print('OnLeftDClick___')
> 




More information about the Python-list mailing list