distutils - distributing non-python data files

RickMuller rpmuller at gmail.com
Tue Oct 25 13:35:53 EDT 2005


I really appreciate the ease that the distutils make distributing
Python modules. However, I have a question about using them to
distribute non-Python (i.e. text) data files that support Python
modules. Currently when I have data of this type, I parse it into
python objects and make a python module from it. In other words, given
a data file like

% cat grocery_list.txt
eggs
spam
cheese

I would make a data structure like
grocery_list = ['eggs', 'spam', 'cheese']
which can be easily imported from a python file, and which the
distutils installation programs make it easy for me to find on the
Python path.

Of course, the data I'm using is much more complex than this, but you
get the idea. I'm starting to feel like this is a Bad Thing, because if
the data file is distributed as a plain text file (e.g. data values in
columns), I'm putting a barrier to updating the data if I have to parse
a new file into Python. But I don't know whether there is a better way
to include a file like 'grocery_list.txt' in my python
distutils-distributed module so that I can get it from my other python
modules?




More information about the Python-list mailing list