Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #78496

Re: Keepin constants, configuration values, etc. in Python - dedicated module or what?

References (1 earlier) <36d7ddca-29f4-403c-a64d-611e187afc3a@googlegroups.com> <bgtqfb-ndq.ln1@chris.zbmc.eu> <a140612a-a30d-43eb-93a3-bc08b76b5721@googlegroups.com> <mailman.14489.1412095890.18130.python-list@python.org> <2ea96bcf-e905-4d77-a105-82b27715aa6e@googlegroups.com>
Date 2014-10-01 03:15 +1000
Subject Re: Keepin constants, configuration values, etc. in Python - dedicated module or what?
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.14490.1412097338.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Wed, Oct 1, 2014 at 3:01 AM, Rustom Mody <rustompmody@gmail.com> wrote:
>> And you get expressions for free - simple stuff like
>> "7*24*60*60" to represent the number of seconds in a week (for people
>> who aren't intimately familiar with 604800), or calculations relative
>> to previous data, or whatever. Sometimes it's helpful to have just a
>> little code in your data.
>
> Not free at all. Power of code means cost of code
> See http://www.w3.org/2001/tag/doc/leastPower.html

It's free once you've already decided (for other reasons) to make your
config file use Python syntax, at which point you've already paid the
cost of code. But you're quite right, allowing code does have costs.
Most notably, you have to quote your strings; although the direct
benefits you get (line continuation, unambiguous handling of
leading/trailing spaces, etc) may outweigh that on their own.

> I'd reiterate though what I first said: In this case its probably
> ok if the code (=data) does not cross trivial limits

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 *".

ChrisA

Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Keepin constants, configuration values, etc. in Python - dedicated module or what? cl@isbd.net - 2014-09-30 12:35 +0100
  Re:Keepin constants, configuration values, etc. in Python - dedicated module or what? Dave Angel <davea@davea.name> - 2014-09-30 09:14 -0400
    Re: Re:Keepin constants, configuration values, etc. in Python - dedicated module or what? cl@isbd.net - 2014-09-30 15:55 +0100
      Re: Keepin constants, configuration values, etc. in Python - dedicated module or what? Dave Angel <d@davea.name> - 2014-10-02 14:50 -0400
  Re: Keepin constants, configuration values, etc. in Python - dedicated module or what? Rustom Mody <rustompmody@gmail.com> - 2014-09-30 06:15 -0700
    Re: Keepin constants, configuration values, etc. in Python - dedicated module or what? cl@isbd.net - 2014-09-30 16:06 +0100
      Re: Keepin constants, configuration values, etc. in Python - dedicated module or what? jkn <jkn_gg@nicorp.f9.co.uk> - 2014-09-30 08:59 -0700
      Re: Keepin constants, configuration values, etc. in Python - dedicated module or what? Rustom Mody <rustompmody@gmail.com> - 2014-09-30 09:39 -0700
        Re: Keepin constants, configuration values, etc. in Python - dedicated module or what? Chris Angelico <rosuav@gmail.com> - 2014-10-01 02:51 +1000
          Re: Keepin constants, configuration values, etc. in Python - dedicated module or what? Rustom Mody <rustompmody@gmail.com> - 2014-09-30 10:01 -0700
            Re: Keepin constants, configuration values, etc. in Python - dedicated module or what? Chris Angelico <rosuav@gmail.com> - 2014-10-01 03:15 +1000
              Re: Keepin constants, configuration values, etc. in Python - dedicated module or what? Rustom Mody <rustompmody@gmail.com> - 2014-09-30 10:31 -0700
                Re: Keepin constants, configuration values, etc. in Python - dedicated module or what? Chris Angelico <rosuav@gmail.com> - 2014-10-01 03:46 +1000
              Re: Keepin constants, configuration values, etc. in Python - dedicated module or what? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-10-02 00:49 +1000
                Re: Keepin constants, configuration values, etc. in Python - dedicated module or what? Chris Angelico <rosuav@gmail.com> - 2014-10-02 00:55 +1000
            Re: Keepin constants, configuration values, etc. in Python - dedicated module or what? cl@isbd.net - 2014-09-30 18:30 +0100
              Re: Keepin constants, configuration values, etc. in Python - dedicated module or what? Chris Angelico <rosuav@gmail.com> - 2014-10-01 03:49 +1000
        Re: Keepin constants, configuration values, etc. in Python - dedicated module or what? Rustom Mody <rustompmody@gmail.com> - 2014-10-16 18:24 -0700
  Re: Keepin constants, configuration values, etc. in Python - dedicated module or what? "Neil D. Cerutti" <neilc@norwich.edu> - 2014-09-30 12:16 -0400
    Re: Keepin constants, configuration values, etc. in Python - dedicated module or what? cl@isbd.net - 2014-09-30 18:50 +0100

csiph-web