python modules as user configuration files
Graham Guttocks
graham_guttocks at yahoo.co.nz
Thu Apr 5 15:36:22 EDT 2001
Greetings Python Experts,
For my application, I would like users to have a python module as
a configuration file to define variables and whatnot.
Is there any way to explicitly import a particular file using its full
path name?
Such as:
>>> import /home/graham/config
(to load ~/config.py)
All I could figure out was to append the user's home directory to
sys.path before import.
>>> import os, sys
>>> sys.path.append(os.path.expanduser("~"))
>>> import config
My other question is: is there way to store a python module as a
dot-file (i.e, "~/.config.py"). It seems by default this is not
allowed:
>>> import .config
File "<stdin>", line 1
import .config
^
SyntaxError: invalid syntax
Regards,
Graham
_____________________________________________________________________________
http://my.yahoo.com.au - My Yahoo!
- Have news, stocks, weather, sports and more in one place.
More information about the Python-list
mailing list