[Python-Dev] Status regarding Old vs. Advanced String Formating

"Martin v. Löwis" martin at v.loewis.de
Sat Feb 25 11:20:51 CET 2012


> I find that strange, especially for an expert Python dev. I, a newbie,
> find it far friendlier (and easier for a new programmer to grasp).
> Maybe it's because I use it all the time, and you don't?

That is most likely the case. You learn by practice. For that very
reason, the claim "and easier for a new programmer to grasp" is
difficult to prove. It was easier for *you*, since you started using
it, and then kept using it. I don't recall any particular obstacles
learning % formatting (even though I did for C, not for C++).
Generalizing that it is *easier* is invalid: you just didn't try
learning that instead first, and now you can't go back in a state
where either are new to you.

C++ is very similar here: they also introduced a new way of output
(iostreams, and << overloading). I used that for a couple of years,
primarily because people said that printf is "bad" and "not object-
oriented". I then recognized that there is nothing wrong with printf
per so, and would avoid std::cout in C++ these days, in favor of
std::printf (yes, I know that it does have an issue with type safety).

So I think we really should fight the impression that % formatting
in Python is "bad", "deprecated", or "old-style". Having both
may be considered a slight violation of the Zen, however, I would
claim that neither formatting API are that obvious - AFAIR, the
biggest hurdle in learning printf was to understand the notion
of "placeholder", which I think is the reason why people are coming
up with so many templating systems (templating isn't "obvious").

Regards,
Martin


More information about the Python-Dev mailing list