On Thu, Dec 4, 2008 at 11:35 AM, HT <[EMAIL PROTECTED]> wrote: > A colleague of mine is arguing that since it is easy to write config like: > > FOO = {'bar': ('a': 'b'), 'abc': ('z': 'x')}
I'll assume you meant ('a', 'b') as colons in parens don't make sense. > > in config.py and just import it to get FOO, but difficult to achieve the > same using an ini file and ConfigParser, and since Python files are just > text, we should just write the config options in the Python file and > import it. > > I can think of lots of arguments why this is a bad idea, but I don't > seem to be able to think of a really convincing one. > > Anyone? Well, it is pretty weird to be allowed to put arbitrary code in a mere config file. Have you considered using JSON for the config file format instead? It shares Python's syntax for literals, so you could do: $ cat config.json { "FOO": { "bar": ["a", "b"], "abc": ["z", "x"] } } Note that the whitespace doesn't matter. Also, you can use Python's built-on `json` module to parse the file. Cheers, Chris -- Follow the path of the Iguana... http://rebertia.com > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list