Issue 13280: argparse should use the new Formatter class (original) (raw)
Issue13280
Created on 2011-10-27 20:19 by poke, last changed 2022-04-11 14:57 by admin. This issue is now closed.
Messages (4) | ||
---|---|---|
msg146516 - (view) | Author: Patrick Westerhoff (poke) | Date: 2011-10-27 20:19 |
Hey, according to PEP 3101, the new string.Formatter class is supposed to replace the old string formatting with %. At least that is what I was always thinking. Given that argparse is a Python 3.2+ exclusive module, I think it should make use of that new formatting method. Is there any special reason why that is not the case and the old %-formatting is used? It feels a bit weird to have Python 3 code using only string.Formatter and then have a short section where the old formatter is used – especially when that module was introduced with Python 3.2. | ||
msg146520 - (view) | Author: Florent Xicluna (flox) * ![]() |
Date: 2011-10-27 21:42 |
Well argparse exists since 2006 (ref [1]), and "should work on Python >= 2.3" (ref [2]). It was merged in the standard library with Python 3.2. However, I agree we may switch to the advanced string formatting for this module. [1] http://objectmix.com/python/180879-%5Bann%5D-argparse-module.html [2] http://pypi.python.org/pypi/argparse#compatibility | ||
msg146533 - (view) | Author: Raymond Hettinger (rhettinger) * ![]() |
Date: 2011-10-28 03:14 |
There's no reason to switch the implementation. The % formatting isn't going away and we've decided against doing switch-overs in existing code (it risks introducing bugs while conferring zero benefits to users). | ||
msg326708 - (view) | Author: paul j3 (paul.j3) * ![]() |
Date: 2018-09-30 06:50 |
Thinking about https://bugs.python.org/issue34744, I realized that the new style formatting could provide some added flexibility to the help lines. I think new style formatting could be added in parallel with the existing style, as an alternative, not as a replacement. With that option a help line like: 'help for {dest} or {option_strings[0]} default is {default}' could be used. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:57:23 | admin | set | github: 57489 |
2018-09-30 06:50:24 | paul.j3 | set | messages: + |
2013-08-09 06:00:08 | paul.j3 | set | nosy: + paul.j3 |
2011-10-29 19:45:55 | rhettinger | set | status: open -> closedresolution: not a bug |
2011-10-28 05:32:05 | petri.lehtinen | set | nosy: + petri.lehtinen |
2011-10-28 03:14:34 | rhettinger | set | nosy: + rhettingermessages: + |
2011-10-27 21:57:11 | flox | set | nosy: + bethard |
2011-10-27 21:42:55 | flox | set | priority: normal -> lowversions: - Python 3.2, Python 3.4nosy: + floxmessages: + |
2011-10-27 20:19:11 | poke | create |