Most Pythonic way to store (small) configuration
torriem at gmail.com
Wed Aug 5 06:48:51 CEST 2015
On 08/04/2015 08:44 PM, random832 at fastmail.us wrote:
> On Tue, Aug 4, 2015, at 21:32, Michael Torrie wrote:
>> In many of my projects I put basic config variables in a file like
>> config.py and import that in each module that needs it. The config
>> module doubles as a global namespace for sharing between modules as well.
> What about JSONP? That is, a file consisting exactly of "config_data =
> [JSON object]" That would get you some of the benefits of having your
> config file exist as a python module, but still allow it to be examined
> by other tools, written out, etc.
But I don't need it to be examined by other tools. So the added
complication of yet another layer isn't worth it or needed. Python's
syntax is simple enough that a person with a text editor can certainly
do it. Again, context is everything. My programs are written for
mostly my own use. If I was writing a system that was like, say,
Apache, I would certainly do a DSL with a robust error checking and
reporting system that could clearly help people with syntax errors, etc.
More information about the Python-list