Python Libraries
March 1st, 2006 Posted in Programming, Python
Does anyone have any good "guides" for build nicely self contained Python Libraries? I'm converting a few thousand lines of code from application-specific libraries to thing that will be dropped into site-packages.
While I have a really good idea about what has to be done, I'm looking around for something that says something akin to "good idea, bad idea". For example:
- Logging to the screen, or stderr (unless raising an error) : Bad Idea
- Not properly checking for dependencies : Bad Idea
- Properly raising exceptions (and providing custom ones) : Good Idea
- Unit Tests and PyDoc : Good Idea
I'm still scouring for information, but any suggestions and pointers are welcome.


March 1st, 2006 at 4:42 pm
Using easily-googlable, non-generic package name: good idea.
Adding a README.txt with doctest sections as a usage guide: very very good idea. (Examples: schooltool.relationship,
zope.formlib.)
September 6th, 2006 at 4:58 pm
Packaging/installation with distutils.
Advertising via cheese shop.
Spells out clearly what its platform limitations are.
Has narrative documentation describing how someone might actually use it in the real world.
If a library calls into code that its end user writes, it’s not a library, it’s a framework. If it has its own mainloop, it’s an application, not a library.
September 8th, 2006 at 12:07 am
It doesn’t sound like such a document exists. Perhaps you could write down the things in your own head and start the ball rolling?
Personally, I always feel like I’m probably structuring my code in a way that no one but me will ever understand. :)