|Wednesday, March 12, 2003|
Python Coding Standards
David Jeske posted a very interesting annotated email of a document originally from Yahoo about Python Coding Standards.
In and of itself, the article is quite useful and makes some extremely valuable, though often missed, points regarding how coding style affects the long term value of a body of software.
First, I had no idea that Yahoo! uses Python heavily enough to have warranted the creation of a coding standards document!
However, the part of the article I found to be most interesting-- i.e. most relevant to my daily programming habits-- was the section that discusses method naming conventions.
Public method names should: 1) start with a lower-case letter 2) upper-case the first letter of each word 3) include a description of the required arguments it takes, each followed by an underscore. Here are some examples: def charset_(self, o) ## takes one argument, the charset, in MessagePage.py def getPodForGroup_(self,groupname) ## takes one argument, the "Group", in DataCluster.py def getSubsForUser_(self,username) ## takes one argument, the "User", in userserv.py This is inspired by the Objective-C "descriptive" method syntax:
In the context of PyObjC, the document describes the exact method by which PyObjC advertises the underlying Objective-C APIs.
Every year or so (PyObjC has been around since at least 1996), someone raises the idea of making the ObjC API as advertised on the Python side of the bridge "more Pythonic". The proposal is typically along the lines of removing all those ugly underscores, etc...
Ugly they may be, but they convey valuable information...
A PythonMac thread that discusses the same naming conventions from the perspective of bridging ObjC into Python starts here. We just used a lot more words to say what the above article nicely summarizes...
Stupid PowerBook Trick!
this story, I had to see if it really is true. As demonstrated by the picture to the left, the TiBook does have a magnet in the case and it is surprisingly powerful. The magnets to hold down the keyboard I can understand, but this one has me slightly baffled. Is there another magnet glued to the of the screen assembly?
(If you look closely, my powerbook is sitting on top of a NeXT cube. A rather special cube, at that. It has three NeXTdimension boards in it. I have three 21" NeXT monitors to go with it, but don't have the desk space to set it up.)