[Python-Dev] cpython (3.2): Issue #14123: Explicitly mention that old style % string formatting has caveats

Mark Lawrence breamoreboy at yahoo.co.uk
Mon Feb 27 01:41:51 CET 2012


On 26/02/2012 23:33, Guido van Rossum wrote:
> On Sun, Feb 26, 2012 at 3:14 PM, Terry Reedy<tjreedy at udel.edu>  wrote:
>> On 2/26/2012 5:38 PM, Nick Coghlan wrote:
>>>
>>> Ah, thanks, I knew there was another term that had a new-style
>>> counterpart: percent formatting vs brace formatting.
>>
>> Hooray!
>> Exact parallel and value-neutral.
>
> Can we stop it with the "political correctness" already? The old style
> is best named printf-style formatting because that's the origin of the
> format language, and there are many other programming languages that
> support the same formatting language (with minor variations). I care
> less about what we call the new style -- "new style" or "format
> method" both work for me.
>
> I also would like to suggest that, even if the reality is that we
> can't deprecate it today, *eventually*, at *some* *distant* point in
> the future we ought to start deprecating printf-style formatting -- it
> really does have a couple of nasty traps that keep catching people
> unawares. In the mean time it doesn't hurt to use terms that make
> people ever so slightly uneasy with using the old style for new code,
> while also committing to not throwing it out until Python 4 comes
> around.
>
> That said, for consistency's sake, if you add formatting code to an
> existing module that uses the old style, please stick to the old
> style. And to avoid disasters, also please don't go on a library-wide
> rampage of wholesale conversions. The time to start using the new
> formatting is when writing new modules or packages, or possibly when
> doing a major refactoring/upgrade of an existing module or package.
>
> One thing I'd like to see happening regardless is support for
> new-style formatting in the logging module. It's a little tricky to
> think how that would work, alas -- should this be a property of the
> logger or of the call?
>

Just thinking out loud that a tool along the lines of 2to3 aimed 
specifically at changing string formatting would be some encouragement 
for people to switch.  Maybe a project for someone being looked after on 
the mentors ml?

-- 
Cheers.

Mark Lawrence.



More information about the Python-Dev mailing list