How to store properties
Rob Gaddi
rgaddi at highlandtechnology.invalid
Wed Feb 8 12:31:09 EST 2017
On 02/08/2017 03: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?
>
In the interest of trying to be cross-platform and support fallbacks and
work natively into the system and play nicely with my Qt ecosystem I
decided to use PySide.QtCore.QSettings instead of ConfigParser for a
major application framework I put together. Bloody mistake that was,
but now I'm stuck with it.
JSON's cute, but the format doesn't support inline comments. If you
really need complex arrays and nested data structures in your
configuration files, you're probably wrong.
ConfirgParser if you care about security. Import a raw Python file if
you don't. Solved problem and move on; wheel reinvention is for suckers.
--
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order. See above to fix.
More information about the Python-list
mailing list