Keepin constants, configuration values, etc. in Python - dedicated module or what?
rosuav at gmail.com
Tue Sep 30 19:46:25 CEST 2014
On Wed, Oct 1, 2014 at 3:31 AM, Rustom Mody <rustompmody at gmail.com> wrote:
> On the other hand if you impose a convention: Constants file-module has
> NOTHING but constants, thats a non-formal convention and thats ok.
> If however you mix it up with other (real) code, you'll get a bloody mess.
> This kind of stuff "7*24*60*60" is borderline and in my experience
> its a slippery slope that ends up being more trouble than its worth.
Agreed, and which side of the border it's on is a matter of opinion.
Suppose you were writing an INI-style parser - would you include this
feature? I probably wouldn't include arithmetic, as it's usually more
effort than it's worth, but it isn't a bad feature inherently. I'd
definitely not include backreferencing (FOO = "bar", followed by
FOO_LEN = len(FOO) or something), or the ability to chain assignments
(FOO = BAR = 0), so those would be advised against in the convention
docs. On the other hand, a quoted string requirement ("foo\nbar")
makes a huge amount of sense in certain contexts, and I can imagine
implementing quite a lot of a programming language's string literal
More information about the Python-list