.format vs. %

Steven D'Aprano steve+comp.lang.python at pearwood.info
Tue Jan 3 01:15:59 EST 2012

On Mon, 02 Jan 2012 22:58:23 -0700, Ian Kelly wrote:

> On Mon, Jan 2, 2012 at 8:52 PM, Steven D'Aprano
> <steve+comp.lang.python at pearwood.info> wrote:
>> On Mon, 02 Jan 2012 17:59:43 -0800, Rick Johnson wrote:
>>> On Jan 2, 4:00 pm, Ethan Furman <et... at stoneleaf.us> wrote:
>>>> %-style formatting isn't going away.
>>> You may want to freshen up on the definition of "deprecation".
>> I'm sure Ethan knows the definition of deprecation. I'm sure he also
>> knows that % formatting is NOT deprecated. Please stop spreading FUD
>> about Python features.
> I can't believe I'm taking Rick's side here, but the docs do say:
> "Note: The formatting operations described here are obsolete and may go
> away in future versions of Python. Use the new String Formatting in new
> code."
> http://docs.python.org/py3k/library/stdtypes.html#old-string-formatting-
> I consider that a statement of deprecation, even if it doesn't use the
> term explicitly or describe a definite timeline for removal.

Which is exactly why it is not deprecated: it doesn't say it is 
deprecated and has no timeline for removal. It may not even be removed: 
"may" go away is not "will" go away.

Going around saying that features are deprecated just because they may 
(or may not) some day in the distant future become deprecated is FUD. It 
simply isn't true that % formatting is deprecated: Python Dev has a 
formal process for deprecating code, and that process has not been 
applied to % and there are no plans to do so in the foreseeable future.

There is a huge code base using this feature, including the standard 
library, and Python does not arbitrarily deprecate features used by real 
code without good reason. Just because a number of Python devs want to 
encourage people to use format doesn't imply that % will go away any time 
before Python 4000.


More information about the Python-list mailing list