Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Through SO/P.SE browsing, I've been picking up useful pieces of Python code (e.g. a Mutable memoizer, an efficient prime generator) that I'd like to stick into one spot to have available should I need it in future projects.

What are some best practices for how a "personal" code library of reusable classes/functions/modules should be set up?

For example, do I just drop it all into one module? Or should I model it after the standard library, even though some modules may have 1 class/function in them?

share|improve this question
I need some ideas on this, too. I tend to organize things by subject, and put my code projects in subject-specific folders, and many of them are git repositories for, but it's not easy to call one script from another unless I dump them all in the same folder. – endolith May 25 '13 at 13:19
up vote 3 down vote accepted

Partition it like you would a normal library. There is no reason to include a monster god module if you only need it for one method. The other advantage of organizing pieces into pieces is that it will be easier to find something you need, but haven't used in a while. You don't have to remember that your prime generator comes just before the memoizer in the file. You can just jump straight into the prime module and see the other related methods that you could use but forgot were in your library.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.