[OT] Python and config files?

Hi, friends!

Is there exist a module for working with config file? Simple enough,
just read/write config file (like for most unix app), determine where
row is contain config words with it's parameters (like
'config_word=parameter') or it's a comments (#)?

···

--
Basil Shubin
Freelance Software Developer

You can try dict4ini:

http://wiki.woodpecker.org.cn/moin/Dict4Ini

···

On 10/26/06, Basil Shubin <bashu@yandex.ru> wrote:

Hi, friends!

Is there exist a module for working with config file? Simple enough,
just read/write config file (like for most unix app), determine where
row is contain config words with it's parameters (like
'config_word=parameter') or it's a comments (#)?

--
I like python!
UliPad <<The Python Editor>>: UliPad - Woodpecker Wiki for CPUG
My Blog: http://www.donews.net/limodou

There is one, it is part of the standard distribution of python:

import ConfigParser

cfgfp = open(config_filename, 'rt')
cfgfp.readline()
cfg = ConfigParser.ConfigParser()
cfg.readfp(cfgfp)
cfgfp.close()

And then, e.g.

cfg.get('section01', 'entry01')

Have fun!

Basil Shubin schrieb:

···

Hi, friends!

Is there exist a module for working with config file? Simple enough,
just read/write config file (like for most unix app), determine where
row is contain config words with it's parameters (like
'config_word=parameter') or it's a comments (#)?

Basil Shubin wrote:

Hi, friends!

Is there exist a module for working with config file? Simple enough,
just read/write config file (like for most unix app), determine where
row is contain config words with it's parameters (like
'config_word=parameter') or it's a comments (#)?

Take a look at wx.Config and wx.FileConfig for some wx alternatives.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Matthias Gondan пишет:

There is one, it is part of the standard distribution of python:

import ConfigParser

cfgfp = open(config_filename, 'rt')
cfgfp.readline()
cfg = ConfigParser.ConfigParser()
cfg.readfp(cfgfp)
cfgfp.close()

And then, e.g.

cfg.get('section01', 'entry01')

Exactly what I need! Thanks!

···

--
Basil Shubin
Freelance Software Developer

limodou пишет:

···

On 10/26/06, Basil Shubin <bashu@yandex.ru> wrote:

Hi, friends!

Is there exist a module for working with config file? Simple enough,
just read/write config file (like for most unix app), determine where
row is contain config words with it's parameters (like
'config_word=parameter') or it's a comments (#)?

You can try dict4ini:

http://wiki.woodpecker.org.cn/moin/Dict4Ini

Looks interesting too!

--
Basil Shubin
Freelance Software Developer

Basil Shubin wrote:

Hi, friends!

Is there exist a module for working with config file? Simple enough,
just read/write config file (like for most unix app), determine where
row is contain config words with it's parameters (like
'config_word=parameter') or it's a comments (#)?

Take a look also at ConfigObj - a Python module for easy reading and writing of config files.

http://www.voidspace.org.uk/python/configobj.html

···

--
Best regards,
Alexei Vinidiktov