[Python-Dev] cpython (3.2): Issue #14123: Explicitly mention that old style % string formatting has caveats (original) (raw)

Cameron Simpson cs at zip.com.au
Sun Feb 26 22:39:32 CET 2012


On 27Feb2012 07:13, Nick Coghlan <ncoghlan at gmail.com> wrote: | On Mon, Feb 27, 2012 at 5:23 AM, Eli Bendersky <eliben at gmail.com> wrote: | >> It would be nice to call it something else than "printf-style | >> formatting". While it is certainly modelled on printf(), knowledge of C | >> or printf is not required to understand %-style formatting, nor even to | >> appreciate it. | > | > | > +1. The section is already titled "old string formatting operations" so if | > this name is acceptable it should be reused. If it's not, it should then be | > consistently changed everywhere. || I deliberately chose printf-style as being value neutral (whereas | old-style vs new-style carries a heavier recommendation that you | should be using the new one). Sure you don't need to know printf to | understand it, but it needs some kind of name, and "printf-style" | acknowledges its roots.

+1 here from me too: it is printf in roots and several format specifiers (%d, %s etc). If you know printf you immediately know a lot about what you can expect, and if you don't you know know a little about its roots.

| Another value-neutral term is "mod-style", | which describes how it is invoked (and I believe we do use that in a | few places already).

A -1 on "mod-style" from me. While it does use the "%" operator symbol, in no other way is it like the "mod" arithmetic operation.

I think docs should occasionally hint at preferred approaches. The new new formatting is a deliberate Python change. Without some rationale/editorial it flies in the face of the "one obvious way to do things" notion. It shouldn't be overdone, but neither should it be absent.

Cheers,

Cameron Simpson <cs at zip.com.au> DoD#743 http://www.cskk.ezoshosting.com/cs/

Ignorance is preferable to error; and he is less remote from the truth who believes nothing, than he who believes what is wrong. - Thomas Jefferson



More information about the Python-Dev mailing list