functions - where to store them
lie.1296 at gmail.com
Wed Mar 11 16:04:19 CET 2009
plsullivan1 at gmail.com 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
Note: functioncoll.py must be in your python search path. One way to
easily ensure it is in the search path is to put functioncoll.py in the
same directory as program.py
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