Style Guides

3 views
Skip to first unread message

Jay Loden

unread,
May 2, 2008, 12:49:33 AM5/2/08
to psuti...@googlegroups.com
Just to let you guys know I haven't forgotten about our project:

This is mostly for Dave, since I know Giampaolo has spent a lot of time reading these before ;)

I figured it'd be a good idea to brush up on the PEPs for Python code to make sure our module follows all the conventions. Since my eventual goal would be for psutil to get into the Python standard lib, we might as well make it as easy as possible for the Python developers/users to like it...

PEP 7 - Style Guide for C Code: http://www.python.org/dev/peps/pep-0007/
PEP 8 - Stype Guide for Python: http://www.python.org/dev/peps/pep-0008/

PEP 8's most important section is near the bottom where it talks about module, class, and method naming conventions. We'll have to decide what route we're going to go but I favor avoiding underscores as much as we can and trying to stick to short and sweet names. For instance we already know there will be a Process object, so if you've got Process.pid() it seems obvious that would return the PID of the process, Process.kill() kills it off, or Process.path() returns the file path, etc. I'm sure some of them will probably need longer more descriptive names (returning handle counts, for instance) but like most programmers I hate typing out long method names so I'd prefer to keep stuff as short as we can.

Plus, as a personal preference I'm just not a fan of Object.method_names_that_look_like_this() so the less the better IMO on that front, hehehe.

-Jay

Reply all
Reply to author
Forward
0 new messages