string formatting documentation
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Mon Jan 19 10:01:40 EST 2009
On Mon, 19 Jan 2009 14:44:01 +0000, Alan G Isaac wrote:
> On 1/17/2009 3:59 PM Ned Deily apparently wrote:
>> <http://docs.python.org/3.0/library/stdtypes.html#old-string-
formatting-operations>
>
>
> Ah, so the rumors are true:
> we are supposed to prefer
> '{0:>10}'.format('wtf?')
> to
> '%10s' % 'wtf?'
> and
> '{{0}}{0}'.format('wtf?').format('wtf?') to
> '%%s%s' % 'wtf?' % 'wtf?'
Well, that second example certainly is a WTF.
I think we are supposed to prefer:
'{0}{0}'.format('wtf?')
to
'%%s%s' % 'wtf?' % 'wtf?'
And frankly, I do.
> According to PEP 4,
> "obsolete" means "deprecated".
> So the compact, simple, and useful
> old string formatting is really deprecated? Ouch.
PEP 4 applies to *modules*. String formatting is not a module. Old string
formatting is obsolete but not yet deprecated. Why don't you raise the
issue on python-dev, where it may do some good?
--
Steven
More information about the Python-list
mailing list