help with designing an app. based on ConfigParser

Fredrik Lundh fredrik at pythonware.com
Thu Apr 6 09:11:18 EDT 2006


Alexandre CONRAD wrote:

> But now, how do I hold multiple servers ? In this case, I thought about
> having multiple sections such as
>
>   [SERVER 01]
>   [SERVER 02]
>   [SERVER 03]
>
> But it's not very efficient when I want to parse the WHOLE config file
> to find which servers are available and retrive their options.

ConfigParser will read the entire file in any case, so I'm not sure why sorting the
entries by server rather than by parameter would make things less efficient...

fwiw, I'd probably use

    [server <name>]

where <name> can be chosen freely by the user, as long as it's unique.  e.g.

    [server server10]
    param = ...

    [server dinsdale.foo.org]
    param = ...

    [server nisse]
    param = ...

but I'm the kind of programmer that prefer to keep things simple, so I'm sure you
can find more complicated ways to do things ;-)

</F> 






More information about the Python-list mailing list