.format vs. %

Devin Jeanpierre jeanpierreda at gmail.com
Tue Jan 3 15:02:47 EST 2012


> "one obvious way" != "only one way"

Which way is the obvious way? Why is it obvious?

For me, sprintf-formatting is "obviously" easier to use (less typing)
unless you're pulling values from a dictionary or object, or already
have all the variables stored in a dict you can pass in with **d.

-- Devin

On Tue, Jan 3, 2012 at 8:26 AM, Ethan Furman <ethan at stoneleaf.us> wrote:
> Ian Kelly wrote:
>>
>> I'm not sure it's true that "there are no plans to do so in the
>> foreseeable future."  According to the release notes from Python 3.0,
>> % formatting was supposed to be deprecated in Python 3.1.
>
>
> Eric Smith wrote (from a thread on pydev in 02-2011):
>> The last thread on this I have a reference to was in September 2009. I
>> think was basically the outcome:
>> http://mail.python.org/pipermail/python-dev/2009-September/092399.html
>>
>> So there will be no deprecation, just a gradual shift to PEP 3101
>> formatting.
>
>
> Ian Kelly wrote:
>>
>> Maybe there was a discussion on py-dev
>> where it was decided that % formatting would not be deprecated after
>> all (in which case the misleading "obsolete" note really ought to be
>> removed from the documentation).
>
>
> Agreed that this is a documentation bug.
>
>
> Ian Kelly wrote:
>>
>> The reason for deprecating it is because Python currently has no fewer
>> than three mechanisms for string formatting (not even including
>> ordinary string concatenation), which according to the Zen of Python
>> is two too many.
>
>
> "one obvious way" != "only one way"
>
> ~Ethan~
> --
> http://mail.python.org/mailman/listinfo/python-list



More information about the Python-list mailing list