Re: Help needed on config files
- From: "Rob Wolfe" <rw@xxxxxxxxx>
- Date: 31 Jan 2007 04:59:46 -0800
jvdb 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>
What about this?
# proj.cfg
[PROJECTx]
path=/path/to/dir1
[PROJECTy]
path=/path/to/dir2
# cfg.py
from ConfigParser import ConfigParser
cfg = ConfigParser()
cfg.read("proj.cfg")
for proj in cfg.sections():
path = cfg.items(proj)[0][1]
print "proj: %s, path: %s" % (proj, path)
Is that not enough?
--
HTH,
Rob
.
- References:
- Help needed on config files
- From: jvdb
- Help needed on config files
- Prev by Date: Re: error messages containing unicode
- Next by Date: Re: marshal.loads ValueError
- Previous by thread: Help needed on config files
- Next by thread: Re: Help needed on config files
- Index(es):
Relevant Pages
|