On Oct 29, 2007, at 11:31 AM, RR4CLB wrote:
How do you make a module so you can place all your functions into
it? I want to be able to load the functions in without having a
long list.
A module is simply a .py file (that is for source files) that you do
not execute directly that is somewhere on python path. The python
path typically consists of:
- PYTHONPATH environment variable, if set
- The directory of the script you are executing
- Directories of installed third party packages, if any
- Standard library modules (could be a directory or zip archive)
- site-packages directory where 3rd party modules are often installed
and site.py resides
Note you can inspect and modify the python path using sys.path, or by
setting PYTHONPATH. though the latter should be avoided except as a
temporary measure usually.
Typically if you have a long script that you want to pare down, you
would create one or more .py files in the same directory as the
script containing the functions you need. Then the script can import
them to use the functions, plus they can import each other as needed.
This tutorial page has more info: http://docs.python.org/tut/node8.html
-Casey