Keepin constants, configuration values, etc. in Python - dedicated module or what?
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Wed Oct 1 10:49:16 EDT 2014
Chris Angelico wrote:
> I'd agree, where "trivial limits" is defined by each individual item.
> Going with straight Python code is fine for huge projects with long
> config files, as long as each config entry is itself simple. You even
> get a form of #include: "from otherfile import *".
I would argue the opposite.
If I have a large Python project, with big config files, then the added
complexity of moving the config data into separate files using a
non-executable format (say, JSON or INI) is minimal, and keeping the data
and code separate will pay off. But for small Python projects, with only a
few data values, keeping them separate is overkill.
So, to the Original Poster, I think that depending on the size of your
program and the amount of config data you have to deal with, there's
nothing wrong with including it directly in the module.
--
Steven
More information about the Python-list
mailing list