[issue8556] Confusing string formatting examples
New submission from Jeff McNeil <jeff@jmcneil.net>: I was going through the string formatting examples this evening and noticed this: print '%(language)s has %(#)03d quote types.' % \ {'language': "Python", "#": 2} The example uses a '#' as a map key. This is somewhat misleading as if we had simply left the parenthesis off, the '#' would have been interpreted as an alternate conversion flag. Should be updated to use a more verbose (and less confusing) dictionary key. ---------- assignee: docs@python components: Documentation files: stdtypes.rst.2.6.5.patch keywords: patch messages: 104410 nosy: docs@python, mcjeff priority: normal severity: normal status: open title: Confusing string formatting examples versions: Python 2.6 Added file: http://bugs.python.org/file17115/stdtypes.rst.2.6.5.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue8556> _______________________________________
Éric Araujo <merwok@netwok.org> added the comment: Thanks for the suggestion. Two things: 1. Please provide a unified diff, as explained in http://www.python.org/dev/ 2. I think “number” would be a better placeholder. Regards ---------- nosy: +merwok _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue8556> _______________________________________
Jeff McNeil <jeff@jmcneil.net> added the comment: Attaching a patch against the trunk, unified format, changed to 'number' as per suggestion. ---------- versions: +Python 2.7 -Python 2.6 Added file: http://bugs.python.org/file17155/stdtypes.rst.trunk.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue8556> _______________________________________
Éric Araujo <merwok@netwok.org> added the comment: Looks good to me. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue8556> _______________________________________
Changes by Florent Xicluna <florent.xicluna@gmail.com>: ---------- nosy: +flox _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue8556> _______________________________________
Georg Brandl <georg@python.org> added the comment: Committed in r85609. ---------- nosy: +georg.brandl resolution: -> fixed status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue8556> _______________________________________
participants (4)
-
Florent Xicluna
-
Georg Brandl
-
Jeff McNeil
-
Éric Araujo