[Tutor] where to put data files
Paul Tremblay
phthenry@earthlink.net
Thu Feb 13 22:49:03 2003
I have a script that needs to read from a data file, and I want to know
the best location for the data file.
Right now, I have this line in my setup.py:
data_files=[('data', ['char_set'])],
This means that in a normal installation, the setup scipt will make a
directory /usr/local/data, and put the char_set file there.
The file consits of encoding schemes.
Would it be better to put the data in /etc?
Also, should I use a relative path? I guess if I use a relative path,
then each time the script runs, it will have to check for the location
of the data directoy:
path = sys.path
char_dir = ""
found_char_dir =0
for dir in path:
data_dir = os.join (dir, "data")
if isdir(data_dir):
char_dir = data_dir
found_char_dir=1
last
if not found_char_dir:
print "no character data found. Scipt will not exit"
sys.exit(1)
## code untested ! this is just to illustrate what I mean
I'm looking for the most standard place for such a data file, a place
that will work on different operating systems.
Thanks
Paul
PS Thanks for the pointers and links in making a setup.py script.
Python's documentatin was pretty decent, and after only 2 or 3 hours, I
had a nice script written that worked perfectly. Nice.
--
************************
*Paul Tremblay *
*phthenry@earthlink.net*
************************