Python Libraries

March 1st, 2006 § 3 comments

Does any­one have any good “guides” for build nicely self con­tained Python Libraries? I’m con­vert­ing a few thou­sand 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 look­ing around for some­thing that says some­thing akin to “good idea, bad idea”. For example:

  • Log­ging to the screen, or stderr (unless rais­ing an error) : Bad Idea
  • Not prop­erly check­ing for depen­den­cies : Bad Idea
  • Prop­erly rais­ing excep­tions (and pro­vid­ing cus­tom ones) : Good Idea
  • Unit Tests and PyDoc : Good Idea

I’m still scour­ing for infor­ma­tion, but any sug­ges­tions and point­ers are welcome.

  • Mar­ius Gedminas

    Using easily-googlable, non-generic pack­age name: good idea.

    Adding a README.txt with doctest sec­tions as a usage guide: very very good idea. (Exam­ples: schooltool.relationship,
    zope.formlib.)

  • chrism

    Packaging/installation with distutils.

    Adver­tis­ing via cheese shop.

    Spells out clearly what its plat­form lim­i­ta­tions are.

    Has nar­ra­tive doc­u­men­ta­tion describ­ing how some­one might actu­ally 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 frame­work. If it has its own main­loop, it’s an appli­ca­tion, not a library.

  • TML

    It doesn’t sound like such a doc­u­ment exists. Per­haps you could write down the things in your own head and start the ball rolling?

    Per­son­ally, I always feel like I’m prob­a­bly struc­tur­ing my code in a way that no one but me will ever understand. :)

What's this?

You are currently reading Python Libraries at jessenoller.com.

meta