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


Groups > comp.lang.python > #40797

Re: Config & ConfigParser

From Neil Cerutti <neilc@norwich.edu>
Newsgroups comp.lang.python
Subject Re: Config & ConfigParser
Date 2013-03-07 16:18 +0000
Organization Norwich University
Message-ID <aprsufFajpU1@mid.individual.net> (permalink)
References <61520ad1-9e3c-4eec-b1d9-8a9d8fc7bf0c@googlegroups.com> <5136b87c$0$30001$c3e8da3$5496439d@news.astraweb.com> <mailman.2922.1362542728.2939.python-list@python.org>

Show all headers | View raw


On 2013-03-06, Chris Angelico <rosuav@gmail.com> wrote:
> On Wed, Mar 6, 2013 at 2:31 PM, Steven D'Aprano
><steve+comp.lang.python@pearwood.info> wrote:
>> What configuration settings does your podcast catcher software
>> need? What makes you think it needs any? Don't over-engineer
>> your application from the start. Begin with the simplest thing
>> that works, and go from there.
>
> Agreed. The way I generally do these things is to simply gather the
> config entries into a block of literal assignments at the top of the
> program:
>
> host = "ftp"
> port = 21
> proxy = "192.168.0.3:81"
> user = "transfers"
> password = "secret"

I find it useful to stuff my config info in a class object; It is
prettier than ALLCAPS, and also makes it simple to create and use
new configurations without erasing or commenting out the old one.

class Config:
  host = "ftp"
  port = 21
  proxy = "192.168.0.3:81"
  user = "transfers"
  password = "secret"

How much to engineer stuff is up to you.

-- 
Neil Cerutti

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


Thread

Config & ConfigParser Chuck <galois271@gmail.com> - 2013-03-05 12:09 -0800
  Re: Config & ConfigParser Tim Chase <python.list@tim.thechases.com> - 2013-03-05 15:17 -0600
    Re: Config & ConfigParser Chuck <galois271@gmail.com> - 2013-03-05 15:58 -0800
      Re: Config & ConfigParser Tim Chase <python.list@tim.thechases.com> - 2013-03-05 18:15 -0600
        Re: Config & ConfigParser Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-06 04:04 +0000
  Re: Config & ConfigParser Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-06 03:31 +0000
    Re: Config & ConfigParser Chris Angelico <rosuav@gmail.com> - 2013-03-06 15:05 +1100
      Re: Config & ConfigParser Neil Cerutti <neilc@norwich.edu> - 2013-03-07 16:18 +0000
    Re: Config & ConfigParser Chuck <galois271@gmail.com> - 2013-03-05 20:07 -0800
      Re: Config & ConfigParser Chris Angelico <rosuav@gmail.com> - 2013-03-06 15:19 +1100
        Re: Config & ConfigParser Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-06 04:54 +0000
          Re: Config & ConfigParser Chris Angelico <rosuav@gmail.com> - 2013-03-06 17:09 +1100

csiph-web