You are on the right track. Put your common definitions in a configuration
module like this:
# Config.py
arch_data_dir='/home/dave/mygg/gg1.3/arch_data'
data_dir='/home/dave/mygg/gg1.3/data'
Then in client code, import Config. When you use the names defined in Config you have to prefix them
with the module name like this:
import Config
print Config.data_dir
Alternately you can use either of these forms:
# Get a couple of names from Config into our global namespace
from Config import arch_data_dir, data_dir
or this:
# Get *all* names defined in Config into our global namespace
from Config import *
to make the bare names available in the client.
Kent
Dave S wrote:
Hi there,
I have some common data directories, like
/home/dave/mygg/gg1.3/logs
/home/dave/mygg/gg1.3/data
/home/dave/mygg/gg1.3/datacore
/home/dave/mygg/gg1.3/arch_data
which increasing numbers of scripts are accessing. At the begining of
each script
I end up putting in declarations like
arch_data_dir='/home/dave/mygg/gg1.3/arch_data'
data_dir='/home/dave/mygg/gg1.3/data'
over over. This is OK until I want to move a directory
Somewhere I read about importing a script to define common globals for
all the scripts that import it.
I tried this, and failed - the variable was only valid for the module,
to be expected really :)
Can anyone make a suggestion howto set up common global presets.
Cheers
Dave
___
Tutor maillist - [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist - [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor