data design

Larry Bates larry.bates at websafe.com
Tue Jan 30 09:57:09 EST 2007


Imbaud Pierre wrote:
> The applications I write are made of, lets say, algorithms and data.
> I mean constant data, dicts, tables, etc: to keep algorithms simple,
> describe what is peculiar, data dependent, as data rather than "case
> statements". These could be called configuration data.
> 
> The lazy way to do this: have modules that initialize bunches of
> objects, attributes holding the data: the object is somehow the row of
> the "table", attribute names being the column. This is the way I
> proceeded up to now.
> Data input this way are almost "configuration data", with 2 big
> drawbacks:
>  - Only a python programmer can fix the file: this cant be called a
>    configuration file.
>  - Even for the author, these data aint easy to maintain.
> 
> I feel pretty much ready to change this:
> - make these data true text data, easier to read and fix.
> - write the module that will make python objects out of these data:
> the extra cost should yield ease of use.
> 
> 2 questions arise:
> - which kind of text data?
>     - csv: ok for simple attributes, not easy for lists or complex
>     data.
>     - xml: the form wont be easier to read than python code,
>       but an xml editor could be used, and a formal description
>       of what is expected can be used.
> - how can I make the data-to-object transformation both easy, and able
>   to spot errors in text data?
> 
> Last, but not least: is there a python lib implementing at least part
> of this dream?

Use the configurations module.  It was built to provide a way to parse
configuration files that provide configuration data to program.  It is
VERY fast so the overhead to parse even thousands of lines of config
data is extremely small.  I use it a LOT and it is very flexible and
the format of the files is easy for users/programmers to work with.

-Larry Bates



More information about the Python-list mailing list