Message81961
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. |
|
Date |
User |
Action |
Args |
2009-02-13 18:36:56 | eric.smith | set | recipients:
+ eric.smith, terry.reedy, mark.dickinson, pitrou, LambertDW, ezio.melotti |
2009-02-13 18:36:56 | eric.smith | set | messageid: <1234550216.48.0.0909841403169.issue5237@psf.upfronthosting.co.za> |
2009-02-13 18:36:55 | eric.smith | link | issue5237 messages |
2009-02-13 18:36:53 | eric.smith | create | |
|