[Tutor] Python best practices

Stefan Lesicnik stefan at lsd.co.za
Fri Nov 27 09:03:57 CET 2009

hihi!  (two in 1 day!)

Is there a document, pep, wiki etc that defines best practice for python code?  (maybe its more generic).

I keep stumbling on things I think, it would be nice if someone mentioned this. Some things ive seen

- keep you try blocks as small as possible, so you can isolate the error
- functions should return one value (im not 100% of this one)
- declare variable names in a certain way (place?)
- use the if __name__ == '__main__': main() convention

im sure there are tons more, that i only figure out after stumbling through them. does anyone know if its written down, or stumbling is just part of the learning process?


More information about the Tutor mailing list