[issue8666] Allow ConfigParser.get*() to take a default value

2010-08-09 Thread Łukasz Langa
Łukasz Langa added the comment: Superseded by #6751 in terms of age. A new patch for the functionality is going to be prepared. -- nosy: +lukasz.langa resolution: -> duplicate status: open -> closed superseder: -> Default return value in ConfigParser

[issue8666] Allow ConfigParser.get*() to take a default value

2010-05-10 Thread R. David Murray
R. David Murray added the comment: Rather than a raise_on_bad option, it seems to me it would be better to code a try/except clause in cases where you want the default even if there is an error converting the data in the file. I would expect such cases to be rare, except for cases where you

[issue8666] Allow ConfigParser.get*() to take a default value

2010-05-10 Thread Tim Chase
Tim Chase added the comment: The "raise_on_bad" (I'm ambivalent on the name, but if you come up with a better name, I'd be fine with changing it) allows you to differentiate between an option that isn't provided, and one that is provided, but can't be converted to the specified int/float/bool

[issue8666] Allow ConfigParser.get*() to take a default value

2010-05-10 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc added the comment: what is this "raise_on_bad" additional argument? -- nosy: +amaury.forgeotdarc ___ Python tracker ___ _

[issue8666] Allow ConfigParser.get*() to take a default value

2010-05-09 Thread Tim Chase
Tim Chase added the comment: Yes, the use-case is the same as a dict.get(key, default) which I frequently use -- so it can be used in things like result = some_function( cp.get('MySection', 'MyValue', default='hello'), cp.getint('MySection', 'MyInt', default=42) ) To write so

[issue8666] Allow ConfigParser.get*() to take a default value

2010-05-08 Thread Brian Curtin
Changes by Brian Curtin : -- stage: -> unit test needed ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://

[issue8666] Allow ConfigParser.get*() to take a default value

2010-05-08 Thread Dan Buch
Changes by Dan Buch : -- nosy: +meatballhat ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.o

[issue8666] Allow ConfigParser.get*() to take a default value

2010-05-08 Thread Éric Araujo
Éric Araujo added the comment: I don’t know if this feature request should be discussed on python-ideas first. Do you have real use cases for this, is it just a nice-to-have thing? If it’s accepted, I have some remarks about the patch: - 2.7 is feature-frozen, so you’ll need to target the py3k

[issue8666] Allow ConfigParser.get*() to take a default value

2010-05-08 Thread Brian Curtin
Changes by Brian Curtin : -- stage: -> unit test needed versions: +Python 3.2 -Python 2.6 ___ Python tracker ___ ___ Python-bugs-list

[issue8666] Allow ConfigParser.get*() to take a default value

2010-05-08 Thread Tim Chase
Tim Chase added the comment: Trying a 3rd time to attach the diff (this time from Safari instead of FF) -- keywords: +patch Added file: http://bugs.python.org/file17264/ConfigParser.diff ___ Python tracker

[issue8666] Allow ConfigParser.get*() to take a default value

2010-05-08 Thread Tim Chase
Tim Chase added the comment: For some reason, the diff didn't attach to the previous message. -- ___ Python tracker ___ ___ Python-bug

[issue8666] Allow ConfigParser.get*() to take a default value

2010-05-08 Thread Tim Chase
New submission from Tim Chase : Patch to update ConfigParser.py so that the .get* methods can take an optional parameter rather than raising exceptions. Usage: cp = ConfigParser(...) # ... value = cp.get('MySection', 'MyOption', default='some default') i = cp.getint('MySecton', 'MyInt'