How to store properties

Michael Torrie torriem at gmail.com
Wed Feb 8 10:55:13 EST 2017


On 02/08/2017 04:26 AM, Cecil Westerhof wrote:
> In Java you (can) use a properties file store configuration. What is
> the best way to do something like that in Python?
> I saw ConfigParser, but have the feeling that it is not really used.
> Would a JSON file be a good idea?

I've used ConfigParser before.  I think the relative simpleness of .INI
files.  If I was expecting end users to manipulate a config file, I
would use ConfigParser.

But 90% of the time, I just use another python module.  For my purposes,
there is no security risk to it.  Due to its nature, Django also uses
python modules to define configuration such as URL maps, etc.

When I'm using GTK+, I would use the gsettings facilities of GTK+ to
store and retrieve config variables.  And with Qt, I'd use QSettings. I
think in both cases they use backends appropriate for the operating
system. On Windows, that would be registry settings in the user hive.




More information about the Python-list mailing list