functions - where to store them

Lie Ryan lie.1296 at
Wed Mar 11 16:04:19 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.

Yes of course. It is called module.


def foo(): pass
def bar(): pass

import functioncoll

Note: must be in your python search path. One way to 
easily ensure it is in the search path is to put in the 
same directory as

Note that all the usual tricks with import also works, like
from functioncoll import foo, bar
import functioncoll as fc

More information about the Python-list mailing list