Re: editing conf file

2012-11-16 Thread rusi
On Nov 16, 7:08 pm, Roy Smith wrote: > These days, if I was writing something that needed a config file and I > didn't want to do "import settings" for whatever reason, I would go with > YAML.  It seems to give an attractive mix of: > > * supporting complex data structures > * easy to for humans t

Re: editing conf file

2012-11-16 Thread Roy Smith
Ulrich Eckhardt wrote: > in general importing configuration data by loading and > executing code is a questionable approach. The problem is in particular > that the code parser is always more strict with the syntax than a > configuration file should be. Also, it presents the danger of code >

Re: editing conf file

2012-11-16 Thread Tim Chase
On 11/16/12 07:04, Thomas Bach wrote: > On Fri, Nov 16, 2012 at 01:48:49PM +0100, chip9munk wrote: >> configparser has four functions: get, getboolean, getfloat and getint. >> >> how do I get list from cfg file?! > > AFAIK you have to parse the list yourself. Something like > > my_list = [ s.stri

Re: editing conf file

2012-11-16 Thread chip9munk
On 11/16/2012 2:04 PM, Thomas Bach wrote: On Fri, Nov 16, 2012 at 01:48:49PM +0100, chip9munk wrote: configparser has four functions: get, getboolean, getfloat and getint. how do I get list from cfg file?! AFAIK you have to parse the list yourself. Something like my_list = [ s.strip() for s

Re: editing conf file

2012-11-16 Thread chip9munk
On 11/16/2012 2:02 PM, Ulrich Eckhardt wrote: Am 16.11.2012 13:06, schrieb chip9munk: I would like to use conf file to get all the variables in my code. And it works great. I use the following (simple example): execfile("example.conf", config) print config["value1"] and it works like a ch

Re: editing conf file

2012-11-16 Thread Ulrich Eckhardt
Am 16.11.2012 13:06, schrieb chip9munk: I would like to use conf file to get all the variables in my code. And it works great. I use the following (simple example): execfile("example.conf", config) print config["value1"] and it works like a charm. This works, but in general importing con

Re: editing conf file

2012-11-16 Thread Thomas Bach
On Fri, Nov 16, 2012 at 01:48:49PM +0100, chip9munk wrote: > configparser has four functions: get, getboolean, getfloat and getint. > > how do I get list from cfg file?! AFAIK you have to parse the list yourself. Something like my_list = [ s.strip() for s in cp.get('section', 'option').split(','

Re: editing conf file

2012-11-16 Thread chip9munk
On 11/16/2012 1:35 PM, rusi wrote: And there may be better options (allows nested sections) http://www.voidspace.org.uk/python/configobj.html but it does not seem to work with python 3 I have an issue... configparser has four functions: get, getboolean, getfloat and getint. how do I get list

Re: editing conf file

2012-11-16 Thread rusi
On Nov 16, 5:15 pm, chip9munk <"chip9munk[SSSpAm"@gmail.com> wrote: > ok, I've got it:http://docs.python.org/3.1/library/configparser.html > > works like a charm! > > Sorry for the unnecessary question. :/ Not an issue. And there may be better options (allows nested sections) http://www.voidspace

Re: editing conf file

2012-11-16 Thread chip9munk
ok, I've got it: http://docs.python.org/3.1/library/configparser.html works like a charm! Sorry for the unnecessary question. :/ -- http://mail.python.org/mailman/listinfo/python-list

editing conf file

2012-11-16 Thread chip9munk
Hi all! I would like to use conf file to get all the variables in my code. And it works great. I use the following (simple example): execfile("example.conf", config) print config["value1"] and it works like a charm. Now the problem is I do not know how to edit the conf file... let us say