This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Confusing string formatting examples
Type: Stage:
Components: Documentation Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, eric.araujo, flox, georg.brandl, mcjeff
Priority: normal Keywords: patch

Created on 2010-04-28 04:57 by mcjeff, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
stdtypes.rst.2.6.5.patch mcjeff, 2010-04-28 04:57 patch to rename map key
stdtypes.rst.trunk.patch mcjeff, 2010-05-01 01:13 review
Messages (5)
msg104410 - (view) Author: Jeff McNeil (mcjeff) * Date: 2010-04-28 04:57
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.
msg104667 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-04-30 21:23
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
msg104683 - (view) Author: Jeff McNeil (mcjeff) * Date: 2010-05-01 01:13
Attaching a patch against the trunk, unified format, changed to 'number' as per suggestion.
msg105073 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-05-05 19:02
Looks good to me.
msg118917 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2010-10-17 09:19
Committed in r85609.
History
Date User Action Args
2022-04-11 14:57:00adminsetgithub: 52802
2010-10-17 09:19:11georg.brandlsetstatus: open -> closed

nosy: + georg.brandl
messages: + msg118917

resolution: fixed
2010-09-09 19:05:54floxsetnosy: + flox
2010-05-05 19:02:50eric.araujosetmessages: + msg105073
2010-05-01 01:13:16mcjeffsetfiles: + stdtypes.rst.trunk.patch

messages: + msg104683
versions: + Python 2.7, - Python 2.6
2010-04-30 21:23:57eric.araujosetnosy: + eric.araujo
messages: + msg104667
2010-04-28 04:57:25mcjeffcreate