Most Pythonic way to store (small) configuration

Chris Angelico rosuav at gmail.com
Thu Aug 6 02:07:35 CEST 2015


On Thu, Aug 6, 2015 at 9:43 AM, Tim Chase <python.list at tim.thechases.com> wrote:
> Significant whitespace?  Not usually simple (just stuck touching a
> project where someone committed with tons of trailing whitespaces.
> grumble), so strip 'em off as if they're an error condition.  I've
> never had a config-file where I wanted leading/trailing whitespace as
> significant.

If you're configuring a prompt, sometimes you need to be able to
include a space at the end of it. Since trailing whitespace on a line
in the file itself is a bad idea, you need some way of marking it.
That might mean quoting the string, or having a Unicode or byte escape
like \x20 that means space, or something like that. If you define that
spaces around your equals sign are insignificant, you need the same
sort of system to cope with the possibility of actual leading
whitespace, too.

>> Case in point, systemd configuration files:
>
> The antithesis of "simplicity" ;-)

Ehh... I reckon they're pretty simple. They're somewhat more powerful
than Upstart config files, and pay some complexity cost for that; but
they're a lot simpler than sysvinit "config files" (which are actually
shell scripts), especially with all the dependency handling cruft that
goes into encoded comments. Frankly, I do my best to avoid ever
touching those. I'm not sure what else to compare them against (never
used any init system other than the three just mentioned), so I don't
see systemd files as being particularly complex.

ChrisA


More information about the Python-list mailing list