functions - where to store them

Terry Reedy tjreedy at
Wed Mar 11 20:47:40 CET 2009

plsullivan1 at wrote:
> I have several functions which I would like to store in a different
> directory so several programs can use them. I can't seem to find much
> information about how to call a function if the function code is not
> actually in the script itself.
> The problem: do I have to cut and paste functions into a script or can
> I store them in a directory and call them from a script in another
> directory. If the latter is possible, how is this done? Thanks.

After you follow the other suggestions of read about 'module' and 
'package'.... If you want a module or package available to *all* 
programs (that run with a particular version/installation of Python), 
you can put your module or packages in the 'site-packages' directory. 
On Windows, this is a subdirectory of pythonxy/lib/

 >>> import sys; sys.path
'C:\\WINDOWS\\system32\\', 'C:\\Programs\\Python30\\DLLs', 
'C:\\Programs\\Python30\\lib', 'C:\\Programs\\Python30\\lib\\plat-win', 
'C:\\Programs\\Python30', 'C:\\Programs\\Python30\\lib\\site-packages']

More information about the Python-list mailing list