classification
Title: String formatting example invalid
Type: behavior Stage: resolved
Components: Documentation Versions: Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: eric.smith Nosy List: SilentGhost, doagie, docs@python, eric.smith
Priority: normal Keywords:

Created on 2011-01-09 12:20 by doagie, last changed 2011-01-09 21:17 by eric.araujo. This issue is now closed.

Messages (4)
msg125838 - (view) Author: Ashwin Purohit (doagie) Date: 2011-01-09 12:20
Your example on page http://docs.python.org/tutorial/inputoutput.html is outdated and won't work in Python 2.7:

Basic usage of the str.format() method looks like this:

>>> print 'We are the {} who say "{}!"'.format('knights', 'Ni')
We are the knights who say "Ni!"


Now, all brackets have to have a numeric or keyword argument.
msg125842 - (view) Author: SilentGhost (SilentGhost) * (Python triager) Date: 2011-01-09 13:52
Works as advertised for me. Unless more information is added, it looks like an invalid issue.
msg125843 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2011-01-09 13:56
This feature was added in 2.7 (and 3.1, I think). If the numeric indices are not specified, they take the args in order.
msg125864 - (view) Author: Ashwin Purohit (doagie) Date: 2011-01-09 21:12
Yes, apologies (I was using 2.6).

On Jan 9, 2011 5:52 AM, "SilentGhost" <report@bugs.python.org> wrote:

SilentGhost <ghost.adh@gmail.com> added the comment:

Works as advertised for me. Unless more information is added, it looks like
an invalid issue.

----------
nosy: +SilentGhost

_______________________________________ Python tracker <
report@bugs.python.org> <http://bugs.python...
History
Date User Action Args
2011-01-09 21:17:35eric.araujosetfiles: - unnamed
nosy: eric.smith, SilentGhost, docs@python, doagie
2011-01-09 21:12:13doagiesetfiles: + unnamed

messages: + msg125864
nosy: eric.smith, SilentGhost, docs@python, doagie
2011-01-09 13:56:45eric.smithsetstatus: open -> closed

assignee: docs@python -> eric.smith

nosy: + eric.smith
messages: + msg125843
resolution: not a bug
stage: resolved
2011-01-09 13:52:30SilentGhostsetnosy: + SilentGhost
messages: + msg125842
2011-01-09 12:20:38doagiecreate