[Python-Dev] Status regarding Old vs. Advanced String Formating
Barry Warsaw
barry at python.org
Fri Feb 24 23:02:55 CET 2012
On Feb 24, 2012, at 10:39 PM, Martin v. Löwis wrote:
>> It is a burden for some people to learn and remember the exact details
>> of both systems and exactly how they differ. Having both in the stdlib
>> hurts readability for such people. I would prefer that the stdlib only
>> used {} formatting or if not that, that it only used the simple,
>> hard-to-forget forms of % formatting (%s, %d, %f, without elaboration).
>
>If that issue was getting serious, I would prefer if the .format method
>was deprecated, and only % formatting was kept.
>
>I doubt this is as much of an issue as you think, though.
I personally prefer .format() these days, but I agree that it will be a long
time, if ever, we see one of the styles getting dropped. I don't have much of
a problem with the stdlib containing both styles as appropriate and preferred
by the maintainer, as long as the module is consistent. Also, modules which
provide a format-ish API should accept both styles, such as what logging
currently does. (It's nice that logging also accepts PEP 292 $-strings too,
don't forget about those. :)
-Barry
More information about the Python-Dev
mailing list