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.

Author eric.smith
Recipients LambertDW, eric.smith, ezio.melotti, mark.dickinson, pitrou, terry.reedy
Date 2009-02-13.18:36:53
SpamBayes Score 1.1265233e-10
Marked as misclassified No
Message-id <1234550216.48.0.0909841403169.issue5237@psf.upfronthosting.co.za>
In-reply-to
Content
Terry J. Reedy wrote:
> Terry J. Reedy <tjreedy@udel.edu> added the comment:
> 
> All I am requesting is that
> '{} {} {}'.format(3, 'pi', 3.14) work as
> 
>>>> '%s %s %s' % (3, 'pi', 3.14)
> '3 pi 3.14'
>>>> '{0} {1} {2}'.format(3, 'pi', 3.14)
> '3 pi 3.14'
> 
> do today (3.0).

My string.Formatter subclass (attached to this bug report) does do this:

$ ./python.exe 
Python 2.7a0 (trunk:69516, Feb 11 2009, 14:30:31) 
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from auto_number_formatter_1 import MyFormatter
>>> f = MyFormatter()
>>> f.format('{} {} {}', 3, 'pi', 3.14)
'3 pi 3.14'
>>> 

This is just for vetting the concept, if it's accepted I'll modify
''.format(). It's not a huge change. I just want to make sure that this
implements what people are expecting.

The talk about '{:d}' and the like is just to make sure all the cases
are addressed. I doubt it would often be used that way.

> I should note that the difference between typing {}, which is easy, and
> {1}, is more than just one keystroke because the latter requires
> unshift-1-shift

Agreed.
History
Date User Action Args
2009-02-13 18:36:56eric.smithsetrecipients: + eric.smith, terry.reedy, mark.dickinson, pitrou, LambertDW, ezio.melotti
2009-02-13 18:36:56eric.smithsetmessageid: <1234550216.48.0.0909841403169.issue5237@psf.upfronthosting.co.za>
2009-02-13 18:36:55eric.smithlinkissue5237 messages
2009-02-13 18:36:53eric.smithcreate