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


Groups > comp.lang.python > #78502

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

From cl@isbd.net
Newsgroups comp.lang.python
Subject Re: Keepin constants, configuration values, etc. in Python - dedicated module or what?
Date 2014-09-30 18:50 +0100
Message-ID <c37rfb-hrt.ln1@chris.zbmc.eu> (permalink)
References <54hqfb-nan.ln1@chris.zbmc.eu> <mailman.14488.1412093823.18130.python-list@python.org>

Show all headers | View raw


Neil D. Cerutti <neilc@norwich.edu> wrote:
> On 9/30/2014 7:35 AM, cl@isbd.net wrote:
> > Thus I'd have something like (apologies for any syntax errors):-
> >
> > cfg = { "LeisureVolts": ["AIN0", 0.061256, "Leisure Battery Voltage"],
> >          "StarterVolts": ["AIN1", 0.060943, "Starter Battery Voltage"],
> >          "LeisureAmps1": ["AIN2", 0.423122, "Leisure Battery Current"}
> >
> > (It might be better to makes those lists dictionaries, but it shows
> > the idea)
> 
> Using configparser.ConfigParser to read an ini-format seems like a good 
> idea. I use it for my own numerous fixed format data file definitions, 
> and it's been convenient and even extensible.
> 
> [LeisureVolts]
> Description=Leisure Battery Voltage
> Code=AIN0
> Value=0.061256
> 
> [StarterVolts]
> Description=Starter Battery Voltage
> Code=AIN1
> Value=0.060943
> 
> [LeisureAmps1]
> Description=Leisure Battery Current
> Code=AIN2
> Value=0.423122
> 
That's OK except that it doesn't associate the different sections in
any way, I need another level which includes these to indicate that
these are values read from the ADC.  There's another collection of
config data for values read from the 1-wire bus.

I guess I could have two config files, one for ADC and one for 1-wire.

In fact I think that's the best approach so far.  Ini format files are
human readable (and more to the point editable), I can store them in
the same directory as the database so they will get carried around
with the data and the configparser module is built-in.

-- 
Chris Green
ยท

Back to comp.lang.python | Previous | Next — Previous 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