Re: configparser - which one?

2019-03-27 Thread Ben Finney
plementation). Despite those, yes I would very much prefer to use YAML as a configuration format. (ConfigParser INI format is acceptable. JSON is definitely not, because it has no simple way to put comments in the file.) -- \ “In the long run, the utility of all non-Free software |

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 conf

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 a

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

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

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

configparser - which one?

2019-03-25 Thread Dave
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 to future-proof may code, so what

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

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 Pytho

Re: ConfigParser: use newline in INI file

2019-03-07 Thread tony
er 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

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
> * 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 r

Re: ConfigParser: use newline in INI file

2019-03-07 Thread tony
t; >>>> 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. >> >> If you want to have \n

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: > > > > > > >

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
lly installed (at least not on the OSes I use). > These days, "execute arbitrary code" implies a deliberate attack. Perhaps I should have phrased it differently: I didn't mean to restrict my comments to a deliberate attack. > Now, if you used input validation as an argument,

Re: configparser v/s file variables

2018-06-27 Thread Rob Gaddi
with files provided by the user. Using configparser is far, far safer.   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

Re: configparser v/s file variables

2018-06-27 Thread Jim Lee
configparser is far, far safer.   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 modify the source to achieve

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.

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.

configparser v/s file variables

2018-06-27 Thread Abdur-Rahmaan Janhangeer
what is more recommended and why? using configparser for settings or import variables from file? thanks, Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ -- https://mail.python.org/mailman/listinfo/python-list

Re: Noob confused by ConfigParser defaults

2017-02-20 Thread Tim Chase
On 2017-02-21 00:04, Peter Otten wrote: > Tim Chase wrote: >> On 2017-02-20 10:45, Peter Otten wrote: >>> value = parser.get("section-1", "option-1", fallback="default >>> value") >> >> Huh. Do you remember when this was ad

Re: Noob confused by ConfigParser defaults

2017-02-20 Thread Peter Otten
remember writing my own wrappers multiple > times for exactly these purposes, even to the point of opening an > issue in the hopes of getting something of the like included > > https://lists.gt.net/python/bugs/827378?do=post_view_threaded > > So I'm glad to see it arrived; just

Re: Noob confused by ConfigParser defaults

2017-02-20 Thread Tim Chase
On 2017-02-20 10:45, Peter Otten wrote: > value = parser.get("section-1", "option-1", fallback="default > value") Huh. Do you remember when this was added? I see it in the 3.x docs, but not the 2.x docs. I remember writing my own wrappers multiple times for exactly these purposes, even to the

Re: Noob confused by ConfigParser defaults

2017-02-20 Thread Ian Pilcher
On 02/20/2017 03:45 AM, Peter Otten wrote: You can provide a default value in your code with parser = configparser.ConfigParser() parser.read(configfile) value = parser.get("section-1", "option-1", fallback="default value") Perfect. Thank you! -- =

Re: Noob confused by ConfigParser defaults

2017-02-20 Thread Ian Pilcher
On 02/20/2017 01:39 AM, Ben Finney wrote: I think you misinderstand the semantics of what ‘configparser’ expects https://docs.python.org/3/library/configparser.html#configparser-objects>: You are absolutely correct. Thank

Re: Noob confused by ConfigParser defaults

2017-02-20 Thread Peter Otten
Ian Pilcher wrote: > I am trying to use ConfigParser for the first time (while also writing > my first quasi-serious Python program). Assume that I want to parse a > a configuration file of the following form: > >[section-1] >option-1 = value1 >option-2 = valu

Re: Noob confused by ConfigParser defaults

2017-02-19 Thread Ben Finney
Ian Pilcher writes: > How do a set a default for option-1 *only* in section-1? I think you misinderstand the semantics of what ‘configparser’ expects https://docs.python.org/3/library/configparser.html#configparser-objects>: Default values […] are used in interpolation if an option u

Noob confused by ConfigParser defaults

2017-02-19 Thread Ian Pilcher
I am trying to use ConfigParser for the first time (while also writing my first quasi-serious Python program). Assume that I want to parse a a configuration file of the following form: [section-1] option-1 = value1 option-2 = value2 [section-2] option-1 = value3 option-2 = value4

Re: Referencing section name by interpolation in ConfigParser

2017-01-27 Thread Hans-Peter Jansen
for the typo. > $ cat config.ini > [Foo] > secref: %(section)s/whatever > [Bar] > secref: %(section)s/whatever > $ cat demo.py > import configparser > > > class Interpolation(configparser.BasicInterpolation): > def before_get(self, parser, section, option, v

Re: configparser bug

2017-01-26 Thread Christos Malliopoulos
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

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'/&

configparser bug

2017-01-25 Thread Christos Malliopoulos
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('cfg.py'))[0].split('/'

Re: Referencing section name by interpolation in ConfigParser

2017-01-25 Thread Peter Otten
nybody, how to archive this with minimum fuzz? If you can live with the existing "basic interpolation", i. e. %(...)s, not %{...}s: $ cat config.ini [Foo] secref: %(section)s/whatever [Bar] secref: %(section)s/whatever $ cat demo.py import configparser class Interpolation(configp

Referencing section name by interpolation in ConfigParser

2017-01-24 Thread Hans-Peter Jansen
Hi, I would like to use a interpolated section name, e.g.: [Section] secref: %{section}s/whatever should result in: >>> config['Section']['secref'] 'Section/whatever' Any idea anybody, how to archive this with minimum fuzz? Thanks, Pete -- https://mail.python.org/mailman/listinfo/python-list

Re: ConfigParser: use newline in INI file

2016-10-02 Thread Peter Otten
t;) >> 'a\nb' > > Interesting approach (although it does not work with Python 3: decode > is only for byte-strings and the string-escape encoding is not > defined). The equivalent for Python 3 is >>> import codecs >>> codecs.decode("a\\nb&q

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: > > > > > > &

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 ra

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'

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""" ..

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 --

ConfigParser: use newline in INI file

2016-10-01 Thread Thorsten Kampe
Hi, ConfigParser escapes `\n` in ini values as `\\n`. Is there a way to signal to ConfigParser that there is a line break? Thorsten -- https://mail.python.org/mailman/listinfo/python-list

Re: can ConfigParser deal with repeating section header?

2015-11-12 Thread amorawski
On Thursday, November 12, 2015 at 10:48:11 AM UTC-5, John Zhao wrote: > I have a configuration file with repeating sections, for example, > > [INSTANCE] > Name=a > > [INSTANCE] > Name=b > > > I hope I can use ConfigParser to read the file and store the confi

Re: can ConfigParser deal with repeating section header?

2015-11-12 Thread Tim Chase
On 2015-11-12 07:47, John Zhao wrote: > I have a configuration file with repeating sections, for example, > > [INSTANCE] > Name=a > > [INSTANCE] > Name=b > > I hope I can use ConfigParser to read the file and store the > configuration settings in arrays. >

can ConfigParser deal with repeating section header?

2015-11-12 Thread John Zhao
I have a configuration file with repeating sections, for example, [INSTANCE] Name=a [INSTANCE] Name=b I hope I can use ConfigParser to read the file and store the configuration settings in arrays. Is that possible? Thanks a lot. John -- https://mail.python.org/mailman/listinfo/python

Re: case-sensitive configparser without magical interpolation?

2015-05-22 Thread georgeryoung
On Friday, May 22, 2015 at 1:13:39 PM UTC-4, Ian wrote: > On Fri, May 22, 2015 at 10:59 AM, gy wrote: > > [python 2.7] > > I need to use a configparser that is case-sensitive for option names, but > > does not do magical interpolation of percent sign. > > I.e.: > &

Re: case-sensitive configparser without magical interpolation?

2015-05-22 Thread Ian Kelly
On Fri, May 22, 2015 at 10:59 AM, wrote: > [python 2.7] > I need to use a configparser that is case-sensitive for option names, but > does not do magical interpolation of percent sign. > I.e.: > > [Mapping0] > backupHost = eng%26 > dbNode = v_br_node0001 > > sho

case-sensitive configparser without magical interpolation?

2015-05-22 Thread georgeryoung
[python 2.7] I need to use a configparser that is case-sensitive for option names, but does not do magical interpolation of percent sign. I.e.: [Mapping0] backupHost = eng%26 dbNode = v_br_node0001 should be read (and later written) as is, including capitalization and the percent sign. I

Re: general ConfigParser question [PS]

2013-11-25 Thread Tim Chase
On 2013-11-25 18:29, Tim Chase wrote: > On 2013-11-25 18:32, Rita wrote: > > I was wondering if the default ConfigParser can handle multi line > > strings (especially in the relate section) > > > > [Relate] > > data="parent process A child process B > &g

Re: general ConfigParser question

2013-11-25 Thread Tim Chase
On 2013-11-25 18:32, Rita wrote: > I was wondering if the default ConfigParser can handle multi line > strings (especially in the relate section) > > [Relate] > data="parent process A child process B > Parent process B child process C Yes, though I seem to recall that subs

general ConfigParser question

2013-11-25 Thread Rita
Hi, I was wondering if the default ConfigParser can handle multi line strings (especially in the relate section) For example, if i have system.ini [Global] memory = 1024 [Process A] command = sleep arguments = 100 [Process B] command = nslookup arguments = hostA output = data [Process C

Re: Config & ConfigParser

2013-03-07 Thread Neil Cerutti
On 2013-03-06, Chris Angelico wrote: > On Wed, Mar 6, 2013 at 2:31 PM, Steven D'Aprano > wrote: >> What configuration settings does your podcast catcher software >> need? What makes you think it needs any? Don't over-engineer >> your application from the start. Begin with the simplest thing >> tha

Re: Config & ConfigParser

2013-03-05 Thread Chris Angelico
On Wed, Mar 6, 2013 at 3:54 PM, Steven D'Aprano wrote: > On Wed, 06 Mar 2013 15:19:53 +1100, Chris Angelico wrote: > >> On Wed, Mar 6, 2013 at 3:07 PM, Chuck wrote: >>> I guess my question was more what is a config.file & why/how do I use >>> one. Thanks >> >> In its simplest form, a config file

Re: Config & ConfigParser

2013-03-05 Thread Steven D'Aprano
On Wed, 06 Mar 2013 15:19:53 +1100, Chris Angelico wrote: > On Wed, Mar 6, 2013 at 3:07 PM, Chuck wrote: >> I guess my question was more what is a config.file & why/how do I use >> one. Thanks > > In its simplest form, a config file is one way to change a program's > behaviour without editing th

Re: Config & ConfigParser

2013-03-05 Thread Chris Angelico
On Wed, Mar 6, 2013 at 3:07 PM, Chuck wrote: > I guess my question was more what is a config.file & why/how do I use one. > Thanks In its simplest form, a config file is one way to change a program's behaviour without editing the code. They're helpful when you want to be able to run the same prog

Re: Config & ConfigParser

2013-03-05 Thread Chuck
I guess my question was more what is a config.file & why/how do I use one. Thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: Config & ConfigParser

2013-03-05 Thread Chris Angelico
On Wed, Mar 6, 2013 at 2:31 PM, Steven D'Aprano wrote: > What configuration settings does your podcast catcher software need? What > makes you think it needs any? Don't over-engineer your application from > the start. Begin with the simplest thing that works, and go from there. Agreed. The way I

Re: Config & ConfigParser

2013-03-05 Thread Steven D'Aprano
On Tue, 05 Mar 2013 18:15:20 -0600, Tim Chase wrote: > On 2013-03-05 15:58, Chuck wrote: >> Thanks Tim! So much stuff I haven't thought of before. Out of >> curiosity, what's the benefit of caching the download, instead of >> downloading to the final destination? > > If your connection gets in

Re: Config & ConfigParser

2013-03-05 Thread Steven D'Aprano
On Tue, 05 Mar 2013 12:09:38 -0800, Chuck wrote: > I'm curious about using configuration files. Can someone tell me how > they are used? I'm writing a podcast catcher and would like to set up > some default configurations, e.g. directory, etcOther than default > directory, what are some of

Re: Config & ConfigParser

2013-03-05 Thread Tim Chase
On 2013-03-05 15:58, Chuck wrote: > Thanks Tim! So much stuff I haven't thought of before. Out of > curiosity, what's the benefit of caching the download, instead of > downloading to the final destination? If your connection gets interrupted, the server goes down, etc, you have a partial downl

Re: Config & ConfigParser

2013-03-05 Thread Chuck
Thanks Tim! So much stuff I haven't thought of before. Out of curiosity, what's the benefit of caching the download, instead of downloading to the final destination? So much stuff they never teach you school.So much theory & not enough practice. :( -- http://mail.python.org/mailman/l

Re: Config & ConfigParser

2013-03-05 Thread Tim Chase
On 2013-03-05 12:09, Chuck wrote: > I'm curious about using configuration files. Can someone tell me > how they are used? I'm writing a podcast catcher and would like > to set up some default configurations, e.g. directory, etcOther > than default directory, what are some of the things that

Config & ConfigParser

2013-03-05 Thread Chuck
I'm curious about using configuration files. Can someone tell me how they are used? I'm writing a podcast catcher and would like to set up some default configurations, e.g. directory, etcOther than default directory, what are some of the things that are put in a configuration file? They

Re: Reading properties file in Python, except using ConfigParser()

2012-10-08 Thread justmailharsh
On Friday, October 5, 2012 5:03:01 PM UTC+5:30, Günther Dietrich wrote: > justmailha...@gmail.com wrote: > > > > >How to read properties file in Python? I found ConfigParser() but it has a > > >'section' limitation, so looking for other alternati

Re: Reading properties file in Python, except using ConfigParser()

2012-10-05 Thread Günther Dietrich
justmailha...@gmail.com wrote: >How to read properties file in Python? I found ConfigParser() but it has a >'section' limitation, so looking for other alternatives. Have a look at PyYAML. Best regards, Günther -- http://mail.python.org/mailman/listinfo/python-list

Re: Reading properties file in Python, except using ConfigParser()

2012-10-05 Thread Laszlo Nagy
On 2012-10-05 09:20, justmailha...@gmail.com wrote: Hi All, How to read properties file in Python? I found ConfigParser() but it has a 'section' limitation, so looking for other alternatives. http://wiki.python.org/moin/ConfigParserShootout -- http://mail.python.org/mailman/listi

Reading properties file in Python, except using ConfigParser()

2012-10-05 Thread justmailharsh
Hi All, How to read properties file in Python? I found ConfigParser() but it has a 'section' limitation, so looking for other alternatives. Thanks, Harsh -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there a ConfigParser which keeps comments

2012-03-15 Thread Gelonida N
>> with one minor difference. > | >> > | >> The write() mehtod should keep existing comments. > | > > | > Assuming that you have not overlooked anything, I would just subclass > | > ConfigParser with an altered write method. > | > | It would require a lot

Re: Is there a ConfigParser which keeps comments

2012-03-15 Thread Karim
Le 15/03/2012 03:48, Steven W. Orr a écrit : On 3/14/2012 6:07 AM, Gelonida N wrote: Hi, At the moment I use ConfigParser http://docs.python.org/library/configparser.html for one of my applications. Now I'm looking for a library, which behaves like config parser, but with one

Re: Is there a ConfigParser which keeps comments

2012-03-15 Thread Cameron Simpson
od should keep existing comments. | > | > Assuming that you have not overlooked anything, I would just subclass | > ConfigParser with an altered write method. | | It would require a lot more than that. It would entail changing | the reading as well so that it preserved the comments as well as | t

Re: Is there a ConfigParser which keeps comments

2012-03-15 Thread Steven W. Orr
On 3/14/2012 6:07 AM, Gelonida N wrote: Hi, At the moment I use ConfigParser http://docs.python.org/library/configparser.html for one of my applications. Now I'm looking for a library, which behaves like config parser, but with one minor difference. The write() mehtod should keep exi

Re: Is there a ConfigParser which keeps comments

2012-03-14 Thread Tim Chase
just subclass ConfigParser with an altered write method. It would require a lot more than that. It would entail changing the reading as well so that it preserved the comments as well as the order of sections & keys, and a way of storing those associated comments in sequence. I looked into it a f

Re: Is there a ConfigParser which keeps comments

2012-03-14 Thread Terry Reedy
On 3/14/2012 6:07 AM, Gelonida N wrote: Hi, At the moment I use ConfigParser http://docs.python.org/library/configparser.html for one of my applications. Now I'm looking for a library, which behaves like config parser, but with one minor difference. The write() mehtod should keep exi

Is there a ConfigParser which keeps comments

2012-03-14 Thread Gelonida N
Hi, At the moment I use ConfigParser http://docs.python.org/library/configparser.html for one of my applications. Now I'm looking for a library, which behaves like config parser, but with one minor difference. The write() mehtod should keep existing comments. Does anybody know or impl

Re: (beginner question) ConfigParser nuances

2011-05-02 Thread Unknown Moss
On May 2, 3:25 pm, Chris Rebert wrote: > On Mon, May 2, 2011 at 3:04 PM, Unknown Moss wrote: > > Hi -Beginnerquestionhere. I'm working with ConfigParser. I'd like > > to take a multiline variable and convert it directly to an array. > > Seems like a common  proble

Re: (beginner question) ConfigParser nuances

2011-05-02 Thread Chris Rebert
On Mon, May 2, 2011 at 3:04 PM, Unknown Moss wrote: > Hi - Beginner question here. I'm working with ConfigParser. I'd like > to take a multiline variable and convert it directly to an array. > Seems like a common  problem, but I don't see how I can do it without > doing

(beginner question) ConfigParser nuances

2011-05-02 Thread Unknown Moss
Hi - Beginner question here. I'm working with ConfigParser. I'd like to take a multiline variable and convert it directly to an array. Seems like a common problem, but I don't see how I can do it without doing a little parsing in my own code. Here's what I'm doing ...

Re: Case Sensitive Section names configparser

2010-12-08 Thread Jon Clements
On Dec 8, 10:32 am, RedBaron wrote: > Is there any way by which configParser's get() function can be made > case insensitive? I would probably subclass dict to create a string specific, case insensitive version, and supply it as the dict_type. See http://docs.python.org/library/configparser.html#

Re: Case Sensitive Section names configparser

2010-12-08 Thread Francesco Bochicchio
On 8 Dic, 11:32, RedBaron wrote: > Is there any way by which configParser's get() function can be made > case insensitive? If you don't care about the case of the config parameter values, you could pre-convert the input to configParser all in UPPER or lower letter with a file-

Case Sensitive Section names configparser

2010-12-08 Thread RedBaron
Is there any way by which configParser's get() function can be made case insensitive? -- http://mail.python.org/mailman/listinfo/python-list

question on ConfigParser defaults

2010-11-15 Thread Neal Becker
import ConfigParser # New instance with 'bar' and 'baz' defaulting to 'Life' and 'hard' each config = ConfigParser.SafeConfigParser({'bar': 'Life', 'baz': 'hard'}) config.read('example.cfg') print

Re: ENVIRONMENT Variable expansion in ConfigParser

2010-10-14 Thread Rodrick Brown
How about doing something like host.name=%HOSTNAME% Then when you parse in the value %HOSTNAME% from your configParser module you do a pattern substitution of %HOSTNAME% with os.environ['HOSTNAME']. Sent from my iPhone 4. On Oct 14, 2010, at 7:57 PM, pikespeak wrote: > Hi,

ENVIRONMENT Variable expansion in ConfigParser

2010-10-14 Thread pikespeak
Hi, I am using ConfigParser module and would like to know if it has the feature to autoexpand environment variables. For example currently, I have the below section in config where hostname is hardcoded. I would like it to be replaced with the values from the env variable os.envion['HOSTNAME

Re: Parsing error for ConfigParser

2010-09-23 Thread Philip Semanchuk
On Sep 23, 2010, at 1:22 PM, Andrew Z. wrote: > Is there a way to parse RealPlayer's realplayerrc in Python? I need > to support Python 2.5 - 2.7 > > Example code > > import urllib2 > import ConfigParser > f = urllib2.urlopen('http://pastebin.com/

Parsing error for ConfigParser

2010-09-23 Thread Andrew Z.
Is there a way to parse RealPlayer's realplayerrc in Python? I need to support Python 2.5 - 2.7 Example code import urllib2 import ConfigParser f = urllib2.urlopen('http://pastebin.com/download.php?i=N1AcUg3w') config = ConfigParser.RawConfigParser() config.readfp(f) Error

  1   2   3   >