Ideal Way to Create a Python "Library"
Question: I want to create a "library" of Python modules which I will be able to access
from several separate project folders.

For example, I want the Python scripts in /proj1/ and /proj2/ to have access
to /lib/.

    
    
    /lib/help.py
    /lib/more_help.py
    
    /proj1/script.py
    /proj1/script2.py
    
    /proj2/this_script.py
    /proj2/another_script.py
    

I don't want a single directory with all the Python scripts, as this seems
rather disorganized. I also definitely don't want to copy the same /lib/
script into each of the different projects.

What is the ideal way to handle this in Python? Is it [appending to Python's
path](http://stackoverflow.com/questions/4383571/importing-files-from-
different-folder-in-python)? Or is this more of a hack? This seems to have the
disadvantage of making the files less portable. Or is it [this
question/answer](http://stackoverflow.com/questions/279237/python-import-a-
module-from-a-folder) about using relative paths? Or something else?

I should add that I'm interested in Python 2.x rather than 3.x, if it matters.


Answer: Turn `lib/` into a
[package](http://docs.python.org/tutorial/modules.html#packages), then put it
in one of the directories in `sys.path` (or add a new entry). You can then
import e.g. `lib.help` into your projects.

