Python – How to set up the “personal” library

personal-projectspython

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?

Best Answer

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.

Related Topic