Config & ConfigParser

Neil Cerutti neilc at norwich.edu
Thu Mar 7 17:18:23 CET 2013


On 2013-03-06, Chris Angelico <rosuav at gmail.com> wrote:
> On Wed, Mar 6, 2013 at 2:31 PM, Steven D'Aprano
><steve+comp.lang.python at 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



More information about the Python-list mailing list