[Python-Dev] summary of transitioning from % to {} formatting

Brett Cannon brett at python.org
Sat Oct 3 20:27:20 CEST 2009

On Sat, Oct 3, 2009 at 11:01, Steven D'Aprano <steve at pearwood.info> wrote:
> On Sun, 4 Oct 2009 01:41:36 am Steven Bethard wrote:
>> I thought it might be useful for those who don't have time to read a
>> million posts to have a summary of what's happened in the formatting
>> discussion.
>> The basic problem is that many APIs in the standard library and
>> elsewhere support only %-formatting and not {}-formatting, e.g.
>> logging.Formatter accepts::
>>   logging.Formatter(fmt="%(asctime)s - %(name)s")
>> but not::
>>   logging.Formatter(fmt="{asctime} - {name}")
> Why is this a problem? Is it because the APIs require extra
> functionality that only {} formatting can provide? Possibly, but I
> doubt it -- I expect that the reason is:
> (1) Some people would like to deprecate % formatting, and they can't
> while the std lib uses % internally.
> (2) Some APIs in the std lib are tightly coupled to their internal
> implementation, and so you can't change their implementation without
> changing the API as well.
> Remove either of these issues, and the problem becomes a non-problem,
> and no action is needed. Personally, I'd like to see no further talk
> about deprecating % until at least Python 3.2, that is, the *earliest*
> we would need to solve this issue would be 3.3. As the Zen
> says, "Although never is often better than *right* now."

No one is saying we should deprecate % any time soon on strings
themselves or anywhere. This discussion is purely in regards to
argparse and logging to transition *their* APIs over to {} formatting
which would most likely involve some deprecation for *using* %
formatting in those APIs. But % formatting on strings themselves is
not directly being discussed here.


More information about the Python-Dev mailing list