[Python-Dev] converting the stdlib to str.format

Michael Foord fuzzyman at voidspace.org.uk
Wed Jun 4 13:36:48 CEST 2008


Nick Coghlan wrote:
> Martin v. Löwis wrote:
>>>> Please don't - not before % is actually deprecated (which I hope won't
>>>> happen until Python 4, with removal of % in Python 5, in the year
>>>> when I retire, i.e. 2037).
>>> Now this is news to me -- was there a discussion that changed the
>>> lifetime expectancy of str.__mod__? I'd always supposed it being
>>> deprecated at some point in 3.x.
>>
>> The PEP doesn't specify anything, and I don't recall any discussion,
>> either - the specific timing suggested above is merely my own hopes.
>
> While str.format has an awful lot of points in its favour (no 
> tuple/dict special casing, much cleaner handling of named arguments, 
> access to format options for non-builtin types), there are some 
> debugging cases where I suspect the basic version of % formatting will 
> prove to be more convenient.
>
> At this point in time, my personal preference would be that later in 
> the 3.x series certain aspects of % formatting will be deprecated 
> (acceptance of non-tuples in favour of the format() builtin, 
> acceptance of dicts in favour of str.format), but that simple % 
> formatting of a tuple of values will still be permitted.
>

+1

Simple string formatting with %s and a single object or a tuple meets 
 >90% of my string formatting needs.

Michael Foord

> Cheers,
> Nick.
>



More information about the Python-Dev mailing list