Help needed on config files

Daniele Varrazzo daniele.varrazzo at gmail.com
Wed Jan 31 08:45:46 EST 2007


On Jan 31, 11:04 am, "jvdb" <streamserv... at gmail.com> wrote:
> Hi there,
>
> I am quite new on python programming and need some help on solving my
> problem..
>
> I have to make a (python) program which deletes files from
> directories. I don't think deleting, etc. is the problem. The problem
> is that the directories where i have to delete them are 'dynamic'/
> subject to change. So what i thought is to make a config file
> containing an identifier (useful for myself) and there the directory.
> something like:
> [PROJECTx]
> <path>
> [PROJECTy]
> <path>
>
> I have already seen that there are sorts of modules where you can read
> a config file, but only when you know the key.. Can someone help me
> out on this? The configfile can be altered in time (as there are more
> projects coming where i have to delete files on a scheduled basis).

The classes defined in the ConfigParser module contain a 'sections()'
method that do what you need.

http://docs.python.org/lib/module-ConfigParser.html

Daniele




More information about the Python-list mailing list