Re: configparser - which one?

2019-03-27 Thread Ben Finney
DL Neil writes: > After striking this problem, I was encouraged to take a look at JSON, > and thence YAML. Once there, as they say, didn't look back! > - multi-dimensional possibilities, cf .ini > - similarity/correspondence with Python data structures > - convenient PSL > - easily adopted by (po

Re: configparser - which one?

2019-03-26 Thread DL Neil
On 27/03/19 2:44 AM, Grant Edwards wrote: On 2019-03-26, Cameron Simpson wrote: Like JSON, YAML etc are far far easier than XML for the reader. If "far far easier than XML for the reader" is the bar, then we'll have to keep "nailgun to the eyeballs" on the list... That said, I agree with th

Re: configparser - which one?

2019-03-26 Thread dboland9
Thanks Cameron. Dave, March 26, 2019 12:39 AM, "Cameron Simpson" wrote: > On 25Mar2019 23:24, Dave wrote: > >> On 3/25/19 10:58 PM, DL Neil wrote: >>> On 26/03/19 1:10 PM, Dave wrote: >> >> I use Python3 3, and expected learning how to use configparser >>>would be >> no big deal. Well! >>

Re: configparser - which one?

2019-03-26 Thread Grant Edwards
On 2019-03-26, Cameron Simpson wrote: > Like JSON, YAML etc are far far easier than XML for the reader. If "far far easier than XML for the reader" is the bar, then we'll have to keep "nailgun to the eyeballs" on the list... That said, I agree with the rest of Cameron's post: for simpler stuff

Re: configparser - which one?

2019-03-26 Thread Jon Ribbens
On 2019-03-26, DL Neil wrote: > On 26/03/19 1:10 PM, Dave wrote: >> I use Python3 3, and expected learning how to use configparser would be >> no big deal.  Well!  Seems there is configparser, stdconfigparser, and >> safeconfigparser, and multiple ways to set the section and entries to >> the s

Re: configparser - which one?

2019-03-26 Thread Dave
On 3/26/19 4:29 AM, Terry Reedy wrote: On 3/25/2019 8:10 PM, Dave wrote: I use Python3 3, and expected learning how to use configparser would be no big deal.  Well!  Seems there is configparser, stdconfigparser, and configparser is what IDLE uses.  I would read the extra or deleted features

Re: configparser - which one?

2019-03-26 Thread Terry Reedy
On 3/25/2019 8:10 PM, Dave wrote: I use Python3 3, and expected learning how to use configparser would be no big deal.  Well!  Seems there is configparser, stdconfigparser, and configparser is what IDLE uses. I would read the extra or deleted features of the others and see if they apply to y

Re: configparser - which one?

2019-03-25 Thread Cameron Simpson
On 25Mar2019 23:24, Dave wrote: On 3/25/19 10:58 PM, DL Neil wrote: On 26/03/19 1:10 PM, Dave wrote: I use Python3 3, and expected learning how to use configparser would be no big deal.  Well!  Seems there is configparser, stdconfigparser, and safeconfigparser, and multiple ways to set the s

Re: configparser - which one?

2019-03-25 Thread Dave
On 3/25/19 10:58 PM, DL Neil wrote: Dave, On 26/03/19 1:10 PM, Dave wrote: I use Python3 3, and expected learning how to use configparser would be no big deal.  Well!  Seems there is configparser, stdconfigparser, and safeconfigparser, and multiple ways to set the section and entries to the

Re: configparser - which one?

2019-03-25 Thread DL Neil
Dave, On 26/03/19 1:10 PM, Dave wrote: I use Python3 3, and expected learning how to use configparser would be no big deal.  Well!  Seems there is configparser, stdconfigparser, and safeconfigparser, and multiple ways to set the section and entries to the section.  A little confusing.  I want

Re: ConfigParser: use newline in INI file

2019-03-07 Thread Tim Chase
On 2019-03-07 17:19, tony wrote: > Python 3.5.3 (default, Sep 27 2018, 17:25:39) > >>> "a\\nb".decode("string-escape") > Traceback (most recent call last): > File "", line 1, in > AttributeError: 'str' object has no attribute 'decode' Looks like bytestring.decode('unicode_escape') does what y

Re: ConfigParser: use newline in INI file

2019-03-07 Thread jim . womeldorf
On Thursday, March 7, 2019 at 10:38:03 AM UTC-6, jim.wo...@gmail.com wrote: > On Saturday, October 1, 2016 at 9:57:24 AM UTC-5, Thorsten Kampe wrote: > > Hi, > > > > ConfigParser escapes `\n` in ini values as `\\n`. Is there a way to > > signal to ConfigParser that there is a line break? > > > >

Re: ConfigParser: use newline in INI file

2019-03-07 Thread jim . womeldorf
On Saturday, October 1, 2016 at 9:57:24 AM UTC-5, Thorsten Kampe wrote: > Hi, > > ConfigParser escapes `\n` in ini values as `\\n`. Is there a way to > signal to ConfigParser that there is a line break? > > Thorsten And now we know! I think they should have named Python 3 something else -- htt

Re: ConfigParser: use newline in INI file

2019-03-07 Thread tony
On 07/03/2019 16:58, jim.womeld...@gmail.com wrote: > On Thursday, March 7, 2019 at 8:55:31 AM UTC-6, tony wrote: >> On 07/03/2019 14:16, jim.womeld...@gmail.com wrote: >>> On Saturday, October 1, 2016 at 7:41:40 PM UTC-5, Ned Batchelder wrote: On Saturday, October 1, 2016 at 6:25:16 PM UTC-4,

Re: ConfigParser: use newline in INI file

2019-03-07 Thread Peter Otten
tony wrote: >> On Saturday, October 1, 2016 at 7:41:40 PM UTC-5, Ned Batchelder wrote: >>> If you want to have \n mean a newline in your config file, you can >>> do the conversion after you read the value: >>> >>> >>> "a\\nb".decode("string-escape") >>> 'a\nb' > How does that translate t

Re: ConfigParser: use newline in INI file

2019-03-07 Thread jim . womeldorf
On Thursday, March 7, 2019 at 8:55:31 AM UTC-6, tony wrote: > On 07/03/2019 14:16, jim.womeld...@gmail.com wrote: > > On Saturday, October 1, 2016 at 7:41:40 PM UTC-5, Ned Batchelder wrote: > >> On Saturday, October 1, 2016 at 6:25:16 PM UTC-4, Thorsten Kampe wrote: > >>> * Ben Finney (Sun, 02 Oct

Re: ConfigParser: use newline in INI file

2019-03-07 Thread tony
On 07/03/2019 14:16, jim.womeld...@gmail.com wrote: > On Saturday, October 1, 2016 at 7:41:40 PM UTC-5, Ned Batchelder wrote: >> On Saturday, October 1, 2016 at 6:25:16 PM UTC-4, Thorsten Kampe wrote: >>> * Ben Finney (Sun, 02 Oct 2016 07:12:46 +1100) Thorsten Kampe writes: > Co

Re: ConfigParser: use newline in INI file

2019-03-07 Thread jim . womeldorf
On Saturday, October 1, 2016 at 7:41:40 PM UTC-5, Ned Batchelder wrote: > On Saturday, October 1, 2016 at 6:25:16 PM UTC-4, Thorsten Kampe wrote: > > * Ben Finney (Sun, 02 Oct 2016 07:12:46 +1100) > > > > > > Thorsten Kampe writes: > > > > > > > ConfigParser escapes `\n` in ini values as `\\n`.

Re: configparser v/s file variables

2018-06-28 Thread Jim Lee
On 06/28/18 16:44, Steven D'Aprano wrote: I agree with you that it's a bad idea. Aside from the little fact that you described concerns about using Python code for settings as "silly". Umm, no.  I said that worrying about arbitrary code execution in an interpreted language seemed silly. 

Re: configparser v/s file variables

2018-06-28 Thread Steven D'Aprano
On Thu, 28 Jun 2018 10:58:36 -0700, Jim Lee wrote: > On 06/28/18 07:30, Grant Edwards wrote: >> I still maintain it's a bad idea to run arbitrary code found in >> user-edited config files. >> >> There may be cases where somebody has figured out how to muck with a >> config file that's shared among

Re: configparser v/s file variables

2018-06-28 Thread Jim Lee
On 06/28/18 07:30, Grant Edwards wrote: I still maintain it's a bad idea to run arbitrary code found in user-edited config files. There may be cases where somebody has figured out how to muck with a config file that's shared among multiple users, or has tricked somebody into including somethin

Re: configparser v/s file variables

2018-06-28 Thread Jim Lee
On 06/28/18 00:46, Steven D'Aprano wrote: Yes, attacks by trusted insiders are the hardest to defend against. Betrayal of trust sucks. Trusted users with sufficient privileges could just modify the source code of your application or of Python itself. They could also attack your system in a tho

Re: configparser v/s file variables

2018-06-28 Thread Grant Edwards
On 2018-06-28, Steven D'Aprano wrote: > So why give them the ability to escalate their privilege to that of > your application (which probably can do lots of things they can't > do) by directly executing Python code they supply? To be fair, that situation isn't common. The vast majority of appl

Re: configparser v/s file variables

2018-06-28 Thread Steven D'Aprano
On Wed, 27 Jun 2018 16:09:09 -0700, Jim Lee wrote: > On 06/27/18 15:19, Steven D'Aprano wrote: >> On Wed, 27 Jun 2018 12:15:23 -0700, Jim Lee wrote: >> >>>   It seems a bit silly to me to worry about arbitrary code >>>   execution in >>> an interpreted language like Python whose default runtim

Re: configparser v/s file variables

2018-06-27 Thread Jim Lee
On 06/27/18 15:19, Steven D'Aprano wrote: On Wed, 27 Jun 2018 12:15:23 -0700, Jim Lee wrote:   It seems a bit silly to me to worry about arbitrary code execution   in an interpreted language like Python whose default runtime execution method is to parse the source code directly.  An attac

Re: configparser v/s file variables

2018-06-27 Thread Steven D'Aprano
On Wed, 27 Jun 2018 12:15:23 -0700, Jim Lee wrote: >   It seems a bit silly to me to worry about arbitrary code execution >   in > an interpreted language like Python whose default runtime execution > method is to parse the source code directly.  An attacker would be far > more likely to simply

Re: configparser v/s file variables

2018-06-27 Thread Abdur-Rahmaan Janhangeer
i think variables also in the case of PORT = 12345 Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ And it doesn't require that the end user have any knowlege of Python > syntax or sematics. > -- https://mail.python.org/mailman/listinfo/python-list

Re: configparser v/s file variables

2018-06-27 Thread Grant Edwards
On 2018-06-27, Jim Lee wrote: >  It seems a bit silly to me to worry about arbitrary code > execution in an interpreted language like Python whose default > runtime execution method is to parse the source code directly.  Maybe it's not a deliberate attack. Good application design is also about

Re: configparser v/s file variables

2018-06-27 Thread Rob Gaddi
On 06/27/2018 12:15 PM, Jim Lee wrote: On 06/27/18 11:45, Abdur-Rahmaan Janhangeer wrote: and that closes it, thanks !!! Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ Importing variables from a file is dangerous because it can execute arbitrary code.  It should never be done w

Re: configparser v/s file variables

2018-06-27 Thread Jim Lee
On 06/27/18 11:45, Abdur-Rahmaan Janhangeer wrote: and that closes it, thanks !!! Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ Importing variables from a file is dangerous because it can execute arbitrary code. It should never be done with files provided by the user. Using c

Re: configparser v/s file variables

2018-06-27 Thread Abdur-Rahmaan Janhangeer
and that closes it, thanks !!! Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ Importing variables from a file is dangerous because it can execute > arbitrary code. It should never be done with files provided by the > user. > > Using configparser is far, far safer. > -- https://mail

Re: configparser v/s file variables

2018-06-27 Thread Grant Edwards
On 2018-06-27, Abdur-Rahmaan Janhangeer wrote: > what is more recommended and why? using configparser for settings or import > variables from file? Importing variables from a file is dangerous because it can execute arbitrary code. It should never be done with files provided by the user. Using

Re: configparser bug

2017-01-26 Thread Christos Malliopoulos
Thanx Peter for your prompt response. I replaced tabs with spaces and had no problem reading the file. I think however it is sth to correct in next versions BR Chris On Wed, Jan 25, 2017 at 1:32 PM Peter Otten <__pete...@web.de> wrote: > Christos Malliopoulos wrote: > > > Hi, > > > > I run Ubun

Re: configparser bug

2017-01-25 Thread Peter Otten
Christos Malliopoulos wrote: > Hi, > > I run Ubuntu 16.04 LTS in a VM using VMWare Workstation on a Windows 10 > host. > apt show python-configparser shows 3.3.0r2-2 > On python 2.7.12 I use the following code: > > import configparser as cfg > root = > u'/'.join(os.path.split(os.path.abspath('cf

Re: ConfigParser: use newline in INI file

2016-10-02 Thread Peter Otten
Thorsten Kampe wrote: > * Ned Batchelder (Sat, 1 Oct 2016 17:41:28 -0700 (PDT)) >> If you want to have \n mean a newline in your config file, you can >> do the conversion after you read the value: >> >> >>> "a\\nb".decode("string-escape") >> 'a\nb' > > Interesting approach (although it

Re: ConfigParser: use newline in INI file

2016-10-02 Thread Chris Angelico
On Sun, Oct 2, 2016 at 9:34 PM, Thorsten Kampe wrote: >> If you want to have \n mean a newline in your config file, you can >> do the conversion after you read the value: >> >> >>> "a\\nb".decode("string-escape") >> 'a\nb' > > Interesting approach (although it does not work with Python 3:

Re: ConfigParser: use newline in INI file

2016-10-02 Thread Thorsten Kampe
* Ned Batchelder (Sat, 1 Oct 2016 17:41:28 -0700 (PDT)) > > On Saturday, October 1, 2016 at 6:25:16 PM UTC-4, Thorsten Kampe wrote: > > * Ben Finney (Sun, 02 Oct 2016 07:12:46 +1100) > > > > > > Thorsten Kampe writes: > > > > > > > ConfigParser escapes `\n` in ini values as `\\n`. > > > > Inde

Re: ConfigParser: use newline in INI file

2016-10-01 Thread Ned Batchelder
On Saturday, October 1, 2016 at 6:25:16 PM UTC-4, Thorsten Kampe wrote: > * Ben Finney (Sun, 02 Oct 2016 07:12:46 +1100) > > > > Thorsten Kampe writes: > > > > > ConfigParser escapes `\n` in ini values as `\\n`. > > Indenting solves the problem. I'd rather keep it one line per value > but it s

Re: ConfigParser: use newline in INI file

2016-10-01 Thread Thorsten Kampe
* Ben Finney (Sun, 02 Oct 2016 07:12:46 +1100) > > Thorsten Kampe writes: > > > ConfigParser escapes `\n` in ini values as `\\n`. Indenting solves the problem. I'd rather keep it one line per value but it solves the problem. Thorsten -- https://mail.python.org/mailman/listinfo/python-list

Re: ConfigParser: use newline in INI file

2016-10-01 Thread Thorsten Kampe
* Terry Reedy (Sat, 1 Oct 2016 15:44:39 -0400) > > On 10/1/2016 10:56 AM, Thorsten Kampe wrote: > > > ConfigParser escapes `\n` in ini values as `\\n`. Is there a way to > > signal to ConfigParser that there is a line break? > > Without an example or two, I don't really understand the question e

Re: ConfigParser: use newline in INI file

2016-10-01 Thread Ben Finney
Thorsten Kampe writes: > ConfigParser escapes `\n` in ini values as `\\n`. How do you demonstrate that? Here is an example text of a config file:: >>> import io >>> import textwrap >>> config_text = textwrap.dedent(r""" ... [foo] ... wibble = Lorem\nipsum. ...

Re: ConfigParser: use newline in INI file

2016-10-01 Thread Terry Reedy
On 10/1/2016 10:56 AM, Thorsten Kampe wrote: ConfigParser escapes `\n` in ini values as `\\n`. Is there a way to signal to ConfigParser that there is a line break? Without an example or two, I don't really understand the question enough to answer. -- Terry Jan Reedy -- https://mail.python.

Re: ConfigParser is not parsing

2010-02-12 Thread Rolando Espinoza La Fuente
read() does not return the config object >>> import ConfigParser >>> config = ConfigParser.SafeConfigParser() >>> config.read('S3Files.conf') ['S3Files.conf'] >>> config.sections() ['main'] >>> config.get('main', 'taskName') 'FileConfigDriver' Regards, Rolando Espinoza La fuente www.rolandoespin

Re: ConfigParser examples?

2009-05-16 Thread Esmail
Hi Gabriel, Gabriel Genellina wrote: The (excellent!) article series by Doug Hellmann, "Python Module of the Week", covers ConfigParser (and almost the whole standard library by now). http://www.doughellmann.com/PyMOTW Thanks for the pointer, I hadn't come across this site before, it looks

Re: ConfigParser examples?

2009-05-15 Thread Gabriel Genellina
En Fri, 15 May 2009 18:32:57 -0300, Esmail escribió: Can anyone point to on the web, or possibly share a simple example of the use of the ConfigParser module? The (excellent!) article series by Doug Hellmann, "Python Module of the Week", covers ConfigParser (and almost the whole standard li

Re: ConfigParser and newlines

2009-05-15 Thread Minesh Patel
> Not as best I can tell.  From my /usr/lib/python2.5/ConfigParser.py file, > around line 441: > >  if line[0].isspace() and cursect is not None and optname: >    value = line.strip() >    if value: >      cursect[optname] = "%s\n%s" % (cursect[optname], value) > > That "value = line.strip()" is wh

Re: ConfigParser and newlines

2009-05-15 Thread Tim Chase
test.cfg [Foo_Section] BODY = Line of text 1 Continuing Line of text 1 Executing the code === Python 2.5.1 Stackless 3.1b3 060516 (release25-maint, Mar 6 2009, 14:12:34) [GCC 4.3.0 20080428 (Red Hat 4.3.0-8)] on linux2 Type "help", "copyright", "credits

Re: ConfigParser and newlines

2009-05-15 Thread Mike Driscoll
On May 15, 1:09 pm, Minesh Patel wrote: > I am using ConfigParser to parse a config file and I want to maintain > the newlines, how is it possible. Example given below. BTW, is there > an alternative to configParser, should I use 'exec' instead. Is there > any support for yaml built-in or possibly

Re: ConfigParser subclass problem

2008-09-26 Thread Matimus
On Sep 26, 12:56 pm, Strato <[EMAIL PROTECTED]> wrote: > Hi folks, > > I think I do something wrong, but I don't see why it doesn't work, so I > will explain: > > I've searched in the list archive and found this thread, that explain > exactly what I want to have: the options strings returned by > C

Re: Question re ConfigParser

2008-08-21 Thread loial
On 20 Aug, 13:49, alex23 <[EMAIL PROTECTED]> wrote: > On Aug 20, 5:34 pm, loial <[EMAIL PROTECTED]> wrote: > > > Given a section like > > > [Data] > > value1 > > value2 > > value3 > > > Can ConfigParser be easily used to put the values in a dictionary? If > > so, how? > > Dictionaries are key/value

Re: Question re ConfigParser

2008-08-20 Thread alex23
On Aug 20, 5:34 pm, loial <[EMAIL PROTECTED]> wrote: > Given a section like > > [Data] > value1 > value2 > value3 > > Can ConfigParser be easily used to put the values in a dictionary? If > so, how? Dictionaries are key/value pairs. Do you expect 'value1' to be a key or a value? If the data is li

Question re ConfigParser

2008-08-20 Thread loial
Given a section like [Data] value1 value2 value3 Can ConfigParser be easily used to put the values in a dictionary? If so, how? -- http://mail.python.org/mailman/listinfo/python-list

Re: ConfigParser: Can I read(ConfigParser.get()) a configuration file and use it to call a funciton?

2008-06-26 Thread jamitwidme
Thank you for the answers. Now I understood how to call a function, let me ask you another question. configuration.cfg --- [1234] title: abcd function: efgh --- reading.py -

Re: ConfigParser: Can I read(ConfigParser.get()) a configuration file and use it to call a funciton?

2008-06-26 Thread Matimus
On Jun 26, 7:41 am, [EMAIL PROTECTED] wrote: > Hello. I am a novice programmer and have a question > > I have a configuration file(configuration.cfg) > I read this from reading.py using ConfigParser > When I use ConfigParser.get() function, it returns a string. > I want to call a function that has

Re: ConfigParser: Can I read(ConfigParser.get()) a configuration file and use it to call a funciton?

2008-06-26 Thread Cédric Lucantis
Le Thursday 26 June 2008 16:41:27 [EMAIL PROTECTED], vous avez écrit : > Hello. I am a novice programmer and have a question > > I have a configuration file(configuration.cfg) > I read this from reading.py using ConfigParser > When I use ConfigParser.get() function, it returns a string. > I want to

Re: ConfigParser preserving file ordering

2007-10-19 Thread Gabriel Genellina
En Fri, 19 Oct 2007 10:16:00 -0300, Andrew Durdin <[EMAIL PROTECTED]> escribió: > As for updating ConfigParser -- like most other changes, it probably > needs a champion. ConfigParser is so dumb that should be burned to death and rebuilt from the ashes. -- Gabriel Genellina -- http://mail

Re: ConfigParser preserving file ordering

2007-10-19 Thread Andrew Durdin
On 10/19/07, Frank Aune <[EMAIL PROTECTED]> wrote: > > Yes, but as I said I need functionality present in the standard-library, so > sub-classing ConfigParser is the last option really. Any particular reason you're limited to the standard library? I've used iniparse

Re: ConfigParser preserving file ordering

2007-10-19 Thread Frank Aune
On Friday 19 October 2007 03:42:16 Joshua J. Kugler wrote: > > Have you taken a look at ConfigObj? > > http://www.voidspace.org.uk/python/configobj.html > Yes, but as I said I need functionality present in the standard-library, so sub-classing ConfigParser is the last option really. I was hoping

Re: ConfigParser preserving file ordering

2007-10-18 Thread Joshua J. Kugler
On Thursday 18 October 2007 15:23, Frank Aune wrote: > Hello, > > I use ConfigParser and actually quite like it, EXCEPT that it doesnt > preserve the section order of the original config file when writing a new. > This behaviour is hopeless IMO, and I've been looking for alternatives. > > I've b

Re: configparser shuffles all sections ?

2007-06-22 Thread Fuzzyman
On Jun 23, 1:14 am, Fuzzyman <[EMAIL PROTECTED]> wrote: > On Jun 22, 8:28 pm, Stef Mientki <[EMAIL PROTECTED]> > wrote: > > > > > Nick Craig-Wood wrote: > > > stef <[EMAIL PROTECTED]> wrote: > > >> I just used configparser for the first time and discovered that it > > >> shuffled all my sections,

Re: configparser shuffles all sections ?

2007-06-22 Thread Fuzzyman
On Jun 22, 8:28 pm, Stef Mientki <[EMAIL PROTECTED]> wrote: > Nick Craig-Wood wrote: > > stef <[EMAIL PROTECTED]> wrote: > >> I just used configparser for the first time and discovered that it > >> shuffled all my sections, > >> and the contents of the sections too. > > >> This makes human mani

Re: configparser shuffles all sections ?

2007-06-22 Thread Stef Mientki
Nick Craig-Wood wrote: > stef <[EMAIL PROTECTED]> wrote: >> I just used configparser for the first time and discovered that it >> shuffled all my sections, >> and the contents of the sections too. >> >> This makes human manipulation of the file impossible. >> >> Is there a way to prevent this

Re: configparser shuffles all sections ?

2007-06-22 Thread Steven D'Aprano
On Fri, 22 Jun 2007 09:28:42 +0200, stef wrote: > hello, > > I just used configparser for the first time and discovered that it > shuffled all my sections, > and the contents of the sections too. > > This makes human manipulation of the file impossible. Having read the rest of this thread, I t

Re: configparser shuffles all sections ?

2007-06-22 Thread Nick Craig-Wood
stef <[EMAIL PROTECTED]> wrote: > I just used configparser for the first time and discovered that it > shuffled all my sections, > and the contents of the sections too. > > This makes human manipulation of the file impossible. > > Is there a way to prevent this shuffling, You could try get

Re: configparser shuffles all sections ?

2007-06-22 Thread stef
Marc 'BlackJack' Rintsch wrote: > In <[EMAIL PROTECTED]>, stef wrote: > > >> I just used configparser for the first time and discovered that it >> shuffled all my sections, and the contents of the sections too. >> > > The data is stored in dictionaries. > So there should be some way to

Re: configparser shuffles all sections ?

2007-06-22 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, stef wrote: > I just used configparser for the first time and discovered that it > shuffled all my sections, and the contents of the sections too. The data is stored in dictionaries. > This makes human manipulation of the file impossible. Why so? Ciao, Marc 'Bl

Re: ConfigParser: whitespace leading comment lines

2006-10-13 Thread Fulvio
*** Your mail has been scanned by InterScan MSS. *** On Friday 13 October 2006 04:13, [EMAIL PROTECTED] wrote: > I'd like to propose the following change to ConfigParser.py. IMO there's a reason that left it in such way. Whom didn't like the ConfigParser c

Re: ConfigParser: what read('non-existent-filename') returns in 2.3.x?

2006-07-21 Thread Chris Lambacher
On Thu, Jul 20, 2006 at 02:01:08PM -0700, Danil Dotsenko wrote: > Chris Lambacher wrote: > > On Thu, Jul 20, 2006 at 10:50:40AM -0700, Danil Dotsenko wrote: > >> Wrote a little "user-friedly" wrapper for ConfigParser for a KDE's > >> SuperKaramba widget. > >> (http://www.kde-look.org/content/show.p

Re: ConfigParser: what read('non-existent-filename') returns in 2.3.x?

2006-07-20 Thread Danil Dotsenko
Danil Dotsenko wrote: > Chris Lambacher wrote: >> On Thu, Jul 20, 2006 at 10:50:40AM -0700, Danil Dotsenko wrote: >>> Wrote a little "user-friedly" wrapper for ConfigParser for a KDE's >>> SuperKaramba widget. >>> (http://www.kde-look.org/content/show.php?content=32185) >>> >>> I was using 2.4.x

Re: ConfigParser: what read('non-existent-filename') returns in 2.3.x?

2006-07-20 Thread Danil Dotsenko
Chris Lambacher wrote: > On Thu, Jul 20, 2006 at 10:50:40AM -0700, Danil Dotsenko wrote: >> Wrote a little "user-friedly" wrapper for ConfigParser for a KDE's >> SuperKaramba widget. >> (http://www.kde-look.org/content/show.php?content=32185) >> >> I was using 2.4.x python docs as reference and >>

Re: ConfigParser: what read('non-existent-filename') returns in 2.3.x?

2006-07-20 Thread Chris Lambacher
On Thu, Jul 20, 2006 at 10:50:40AM -0700, Danil Dotsenko wrote: > Wrote a little "user-friedly" wrapper for ConfigParser for a KDE's > SuperKaramba widget. > (http://www.kde-look.org/content/show.php?content=32185) > > I was using 2.4.x python docs as reference and > ConfigParser.read('non-existen

Re: ConfigParser, no attribute

2006-06-05 Thread faulkner
Settings.__init__ needs to call ConfigParser.SafeConfigParser.__init__ before it calls self.readfp. Nexu wrote: > Hello, > > I'm not sure exactly what i'm doing wrong here. I asked around on IRC > and i was told the code is correct. > The purpose of Settings() is that whenever Settings() or any of

Re: ConfigParser and multiple option names

2006-05-10 Thread Florian Lindner
[EMAIL PROTECTED] wrote: > that will break horribly in windows, remenber it install all it's crap > in c:\Program Files Why should this break? If you split at the \n character? Florian -- http://mail.python.org/mailman/listinfo/python-list

Re: ConfigParser and multiple option names

2006-05-05 Thread Ivan Vinogradov
Another option is to use a dedicated section and simply omit values for options: [dirs] /path/1: /long/path/2: /etc: Then get options for section dirs. This approach precludes using ':' or '=' in paths though. -- http://mail.python.org/mailman/listinfo/python-list

Re: [ConfigParser] value with ; and the value blank

2006-05-05 Thread Larry Bates
kai wrote: > Hello, > > how can I use/save/read values with ";" (start comment) and the value > blank? > When I write (set) my config file often the part behind the ";" > disappears. > e.g. > myKey = startMyValue ; endMyValue > > Thank's for your hints, Kai > No, but you can write it as

Re: ConfigParser: values with ";" and the value blank

2006-05-05 Thread André Malo
* kai wrote: > I use the ConfigPaserver from Python. > how can I use/save/read values with ";" (start comment) and the value > blank? > When I write (set) my config file often the part behind the ";" > disappears. > e.g. > myKey = startMyValue ; endMyValue You can't. The ConfigParser tre

Re: ConfigParser and multiple option names

2006-05-05 Thread [EMAIL PROTECTED]
that will break horribly in windows, remenber it install all it's crap in c:\Program Files -- http://mail.python.org/mailman/listinfo/python-list

Re: ConfigParser and multiple option names

2006-05-03 Thread Alexis Roda
Not tested by me, but according to docs it does support list values: http://cheeseshop.python.org/pypi/ConfigObj Regards -- http://mail.python.org/mailman/listinfo/python-list

Re: ConfigParser and multiple option names

2006-05-03 Thread Caleb Hattingh
I have had this same problem before, and what I ended up doing was writing my own far more limited config parser that would create lists for repeated named assignments. Who is the maintainer of ConfigParser? Perhaps a keyword option can be added so that this kind of behaviour can be added at cre

Re: ConfigParser and multiple option names

2006-05-02 Thread alisonken1
Benji York wrote: > > I generally do this: > > dirs = > /home/florian > /home/john > /home/whoever > > ...and then use str.split() in my program. > -- > Benji York The only problem with this would be if you plan on updating the config file later in the program - I don't think Con

Re: ConfigParser and multiple option names

2006-05-02 Thread Benji York
Florian Lindner wrote: > since ConfigParser does not seem to support multiple times the same option > name, like: > > dir="/home/florian" > dir="/home/john" > dir="/home/whoever" I generally do this: dirs = /home/florian /home/john /home/whoever ...and then use str.split() in my

Re: ConfigParser and multiple option names

2006-05-02 Thread alisonken1
Florian Lindner wrote: > Hello, > since ConfigParser does not seem to support multiple times the same option > name, like: > > dir="/home/florian" > dir="/home/john" > dir="/home/whoever" Another option would be to switch to the XMLParser library and use an XML file for the configuration. That w

Re: ConfigParser and multiple option names

2006-05-02 Thread Edward Elliott
Florian Lindner wrote: > I think the best solution would be to use a seperation character: > > dir="/home/florian, /home/john, home/whoever" > > What character would be best to work on various operating systems? (of > what names may a path consist is the question) I don't think there are any uni

Re: ConfigParser and multiple option names

2006-05-02 Thread Larry Bates
Florian Lindner wrote: > Hello, > since ConfigParser does not seem to support multiple times the same option > name, like: > > dir="/home/florian" > dir="/home/john" > dir="/home/whoever" > > (only the last one is read in) > > I wonder what the best way to work around this. > > I think the best

Re: ConfigParser and multiple option names

2006-05-02 Thread Florian Lindner
Alexis Roda wrote: > Florian Lindner escribió: >> I think the best solution would be to use a seperation character: >> >> dir="/home/florian, /home/john, home/whoever" > > RCS uses , in filenames A kommata (,) is a valid character in path names. Ok, you can use quotes. >> What do you think? An

Re: ConfigParser and multiple option names

2006-05-02 Thread Alexis Roda
Florian Lindner escribió: > I think the best solution would be to use a seperation character: > > dir="/home/florian, /home/john, home/whoever" RCS uses , in filenames > What do you think? Any better ideas? A bit ugly, but probably safer and simpler than adding arbitrary separators: [section]

Re: ConfigParser and unicode: a simple solution?

2006-02-22 Thread Fuzzyman
Terry Hancock wrote: > On Wed, 22 Feb 2006 23:42:37 +0100 > Frank Niessink <[EMAIL PROTECTED]> wrote: > > I'm using ConfigParser to read and write simple > > configuration files. > > > > However, filenames may not be simple ascii strings, but > > can very well be > > unicode strings. > http://ww

Re: ConfigParser and unicode: a simple solution?

2006-02-22 Thread Terry Hancock
On Wed, 22 Feb 2006 23:42:37 +0100 Frank Niessink <[EMAIL PROTECTED]> wrote: > I'm using ConfigParser to read and write simple > configuration files. > > However, filenames may not be simple ascii strings, but > can very well be > unicode strings. http://www.google.com/search?hl=en&q=ConfigPa

Re: ConfigParser: writes a list but reads a string?

2006-01-23 Thread Fuzzyman
Jeffrey Barish wrote: > funkyj wrote: > > > making the config file XML and using xml.dom is another option, > > although XML is a bit ugly to edit by hand. > > --jfc > > > I am seriously intrigued by ConfigObj. I am currently using an crude > improvisation involving tab-delimited fields to stor

Re: ConfigParser: writes a list but reads a string?

2006-01-22 Thread Jeffrey Barish
funkyj wrote: > making the config file XML and using xml.dom is another option, > although XML is a bit ugly to edit by hand. > --jfc > I am seriously intrigued by ConfigObj. I am currently using an crude improvisation involving tab-delimited fields to store metadata for recordings -- not conf

Re: ConfigParser: writes a list but reads a string?

2006-01-21 Thread Fuzzyman
funkyj wrote: > I'm interested in the same sort of config file issues. > > Unfortunately the restricted execution has fallen out of favor. My > preferred solution would be to have a configEval() function that is > just like the regular Python eval() but only accepts a subset of the > python langu

Re: ConfigParser: writes a list but reads a string?

2006-01-20 Thread funkyj
I'm interested in the same sort of config file issues. Unfortunately the restricted execution has fallen out of favor. My preferred solution would be to have a configEval() function that is just like the regular Python eval() but only accepts a subset of the python language, e.g. creating the bas

Re: ConfigParser: writes a list but reads a string?

2006-01-17 Thread Terry Carroll
On Tue, 17 Jan 2006 09:11:24 -0600, Larry Bates <[EMAIL PROTECTED]> wrote: >To read lists from .INI files I use following: > >listvalues=INI.get(section, option).split(',') > >where INI is an instance of ConfigParser > >There is the problem of if list items contain commas. Thanks; that's basical

Re: ConfigParser: writes a list but reads a string?

2006-01-17 Thread Larry Bates
Terry Carroll wrote: > It looks like ConfigParser will accept a list to be writing to the > *.ini file; but when reading it back in, it treats it as a string. > > Example: > > ### > import ConfigParser > def whatzit(thingname, thing): >print thingname, "value:", th

Re: ConfigParser: writes a list but reads a string?

2006-01-16 Thread Fuzzyman
Note that ConfigObj also supports type conversion via the ``validate`` module which comes with it. This validates a config file against an (optional) ``configspec`` which you supply, and does all the conversion. It reports any errors it encounters. Syntax for reading and writing is a standard 'ini

Re: ConfigParser: writes a list but reads a string?

2006-01-16 Thread Frithiof Andreas Jensen
"Terry Carroll" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > It looks like ConfigParser will accept a list to be writing to the > *.ini file; but when reading it back in, it treats it as a string. ConfigParser is nasty because it does not really support type conversions but still

Re: ConfigParser: writes a list but reads a string?

2006-01-16 Thread Fuzzyman
ConfigObj will read and write list values. You get all sorts of other advantages as well (nested subsections to any depth), and the resulting code will be much simpler. from configobj import ConfigObj cfgfile = "cfgtest.ini" cfg = ConfigObj(cfgfile) t1 = range(1,11) # no *need* to create a subse

Re: ConfigParser: writes a list but reads a string?

2006-01-16 Thread Sybren Stuvel
Terry Carroll enlightened us with: > It looks like ConfigParser will accept a list to be writing to the > *.ini file; but when reading it back in, it treats it as a string. It doesn't say so explicitly in the manual, but I did find this: """The values in defaults must be appropriate for the "%(

Re: ConfigParser : overwrite ?

2005-07-17 Thread cantabile
Robert Kern a écrit : > cantabile wrote: > >> Hi, I'm trying and updating an .ini file with ConfigParser but each time >> I call 'write', it appends the whole options another time to the file. >> For example : >> Here's the inital ini file >> >> [section1] >> foodir: %(dir)s/whatever >> dir: foo >

Re: ConfigParser : overwrite ?

2005-07-17 Thread Robert Kern
cantabile wrote: > Hi, I'm trying and updating an .ini file with ConfigParser but each time > I call 'write', it appends the whole options another time to the file. > For example : > Here's the inital ini file > > [section1] > foodir: %(dir)s/whatever > dir: foo > > Here's my code : > filename =

  1   2   >