[Tutor] Configuration File Pattern

Lie Ryan lie.1296 at gmail.com
Mon Jul 21 20:23:07 CEST 2008


> Message: 9
> Date: Mon, 21 Jul 2008 16:08:45 +0200
> From: Daniele <d.conca at gmail.com>
> Subject: [Tutor] Configuration File Pattern
> To: tutor at python.org
> Message-ID:
>         <537341c70807210708x52faac7dy44cb850d4a7c4bc6 at mail.gmail.com>
> 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.



More information about the Tutor mailing list