[issue6751] Default return value in ConfigParser
Łukasz Langa luk...@langa.pl added the comment: This issue is superseded by #9421. -- resolution: - duplicate status: open - closed superseder: - configparser.ConfigParser's getint, getboolean and getfloat don't accept `vars` ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6751 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6751] Default return value in ConfigParser
Juan Javier jjdomingu...@gmail.com added the comment: I would like the method to have the exact same behavior as before if the default argument is not present, and return the given default value when deafult argument is present. If you simply add a default keyword, it will always be present and you wouldn't know if the user wants the exception thrown or the default value returned. Do you know how to program this using a default keyword argument? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6751 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6751] Default return value in ConfigParser
Changes by Éric Araujo mer...@netwok.org: -- nosy: +lukasz.langa, merwok ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6751 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6751] Default return value in ConfigParser
Éric Araujo mer...@netwok.org added the comment: Why is it needed to add varargs and kwargs instead of only a new “default” argument? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6751 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6751] Default return value in ConfigParser
Juan Javier jjdomingu...@gmail.com added the comment: I've applied the enhancement to the three parsers, actually I've made the change to RawconfigParser with a small change to ConfigParser. I've also created some unit tests. -- keywords: +patch Added file: http://bugs.python.org/file18122/configparser.py.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6751 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6751] Default return value in ConfigParser
Changes by Juan Javier jjdomingu...@gmail.com: Added file: http://bugs.python.org/file18123/test_cfgparser.py.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6751 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6751] Default return value in ConfigParser
Amaury Forgeot d'Arc amaur...@gmail.com added the comment: The idea is fine (dict.get also has a 'default' parameter) but this patch is very incomplete: - the enhancement should be applied to the three Parsers - it needs unit tests. -- nosy: +amaury.forgeotdarc ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6751 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6751] Default return value in ConfigParser
Mark Lawrence breamore...@yahoo.co.uk added the comment: A short inline patch is proposed, would something like this be acceptable? -- nosy: +BreamoreBoy stage: - patch review ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6751 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6751] Default return value in ConfigParser
New submission from Juan Javier jjdomingu...@yahoo.com: I think it is useful, at least for me, to add an argument, default, to [Safe,Raw]ConfigParser.get that, if present, will be returned if the methid fails to return the value. That is, instead of rasing an exception, return default, if present. It could be done overriding the get method in SafeConfigParser, something like this: class SafeConfigParser(ConfigParser): def get(self, section, option, raw=False, vars=None, **kwds): try: return super().get(section, option, raw, vars) except Exception as exc: if default in kwds: return kwds[default] raise exc -- components: Library (Lib) messages: 91808 nosy: jjdominguezm severity: normal status: open title: Default return value in ConfigParser type: feature request versions: Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6751 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com