[Python-Dev] transitioning from % to {} formatting (original) (raw)

Steven Bethard steven.bethard at gmail.com
Wed Sep 30 02:27:31 CEST 2009


There's a lot of code already out there (in the standard library and other places) that uses %-style formatting, when in Python 3.0 we should be encouraging {}-style formatting. We should really provide some sort of transition plan. Consider an example from the logging docs:

logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")

We'd like to support both this style as well as the following style:

logging.Formatter("{asctime} - {name} - {levelname} - {message}")

Perhaps we'd eventually deprecate the %-style formatting, but at least in the intervening time, we'd have to support both. I see a few possibilities:

Thoughts?

Steve

Where did you get that preposterous hypothesis? Did Steve tell you that? --- The Hiphopopotamus



More information about the Python-Dev mailing list