ConfigParser - add a stop sentinel?
lbates at syscononline.com
Wed Jan 12 18:39:31 CET 2005
You should probably consider NOT doing what you suggest. You
would need to do some rather extensive work so you can support
the .write method of ConfigParser. With a little ingenuity
I've been able to user ConfigParser to support some very
different and complex syntaxes on different projects. If this
won't work, just have two different (separate) files.
If you are dead set on combining these two, put your foreign
syntax lines into the file as comments. ConfigParser will
not process them, and you can have some other class extract
only the comments and parse them independently.
> I am working with PythonCard in one of my apps. For its purposes, it
> uses an .ini file that is passed to ConfigParser. For my app, I also
> need configuration information, but for various reasons, I'd rather
> use a syntax that ConfigParser can't handle.
> I know I can maintain two separate configuration files, and if I have
> to I will, but I'd rather avoid that, if possible, and a solution
> that suits my purposes is quite straightforward. I insert a sentinel
> in the ini file and modify my local ConfigParser's _read method to
> stop accepting input when it encounters that value. I handle my app's
> portion of the configuration myself.
> This all works fine, but I was wondering whether it might be
> worthwhile to add a standard stop flag in ConfigParser itself. Am I
> the only one with this sort of use case? If there were a standard way
> of doing this, I'd much rather use that, particularly if I ever have
> reason to distribute the app elsewhere.
More information about the Python-list