Re: [Tutor] Configuration File Pattern

2008-07-21 Thread Lie Ryan
 Message: 9
 Date: Mon, 21 Jul 2008 16:08:45 +0200
 From: Daniele [EMAIL PROTECTED]
 Subject: [Tutor] Configuration File Pattern
 To: tutor@python.org
 Message-ID:
 [EMAIL PROTECTED]
 Content-Type: text/plain; charset=UTF-8
 
 Hi list,
 I've recently developed a basic python program which needs to store
 some data in a file (e.g. a directory path).
 What the program needs is a dictionary containing the data, so I used
 the pickle module to store the dictionary in a file and read it back
 when the program is launched.
 I wanted to know which is the common pattern in python programming in
 this case, because the way I've choosen only lets the user configure
 the data via a GUI (the file is somehow compiled). Is it better to
 store the data in a text file and then parse it and construct a
 dictionary? Or is there e third way?

Following the Unix philosophy (Store data in flat text file), it is
much better to dump the dictionary into a plain text file, but pickling
is so damn easy. If you have the time and space to do it, you should
make a dumper and parser, if not, there is no real problem with using
pickled format as far as I'm aware (especially if you strictly don't
want someone to manually modify the file). 

The only potential problem, I could think of, is whether pickled data is
cross-version compatible.

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Configuration File Pattern

2008-07-21 Thread Daniele
 What I use in this situation is the INI config file parser in the
 standard lib.  It's easy to use

 http://docs.python.org/lib/module-ConfigParser.html


Awesome!
Really easy and intuitive.
Thanks a lot
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor