[sugar] Python Style Guide

Ian Bicking ianb
Mon Nov 13 13:53:23 EST 2006


Ivan mentioned that there was someone willing to update all the OLPC 
code once we have a style guide.

With that in mind I put together a draft of a style guide: 
http://wiki.laptop.org/go/Python_Style_Guide

This is primarily a copy of PEP 8: 
http://www.python.org/dev/peps/pep-0008/ -- I think we discussed most of 
the variances the current code has from PEP 8 a couple months ago, and I 
think everyone was okay with changing the code in those ways.  But of 
course, there were other things to attend to at the time; having someone 
else volunteer to do the change makes this relevant again.

I've marked a number of things I'm unsure of with [note: ...].  Several 
of these are about code (and other file) layout issues, which don't 
matter too much to an initial changeover of the code. 
Internationalization style remains; I think someone besides myself would 
be better at specifying the style for these.

We might want to consider setting up a pylint profile for this style. 
pylint (http://www.logilab.org/projects/pylint) is notable among Python 
source checkers for being anal about style and other small details. 
Whoever is updating the code for the style might start out by tweaking 
pylint until it can detect all the details we want to update.  It's also 
better to stick to the easy/mechanical updates to start with, and avoid 
updates that might introduce bugs.  Probably it would make sense to 
annotate the style guide rules with "code already should conform", "we 
will update current code" and "code will be updated when possible".

-- 
Ian Bicking | ianb at colorstudy.com | http://blog.ianbicking.org


More information about the Sugar-devel mailing list