Movatterモバイル変換


[0]ホーム

URL:


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

Guido van Rossumguido at python.org
Mon Feb 27 00:33:51 CET 2012


On Sun, Feb 26, 2012 at 3:14 PM, Terry Reedy <tjreedy at udel.edu> wrote:> On 2/26/2012 5:38 PM, Nick Coghlan wrote:>>>> Ah, thanks, I knew there was another term that had a new-style>> counterpart: percent formatting vs brace formatting.>> Hooray!> Exact parallel and value-neutral.Can we stop it with the "political correctness" already? The old styleis best named printf-style formatting because that's the origin of theformat language, and there are many other programming languages thatsupport the same formatting language (with minor variations). I careless about what we call the new style -- "new style" or "formatmethod" both work for me.I also would like to suggest that, even if the reality is that wecan't deprecate it today, *eventually*, at *some* *distant* point inthe future we ought to start deprecating printf-style formatting -- itreally does have a couple of nasty traps that keep catching peopleunawares. In the mean time it doesn't hurt to use terms that makepeople ever so slightly uneasy with using the old style for new code,while also committing to not throwing it out until Python 4 comesaround.That said, for consistency's sake, if you add formatting code to anexisting module that uses the old style, please stick to the oldstyle. And to avoid disasters, also please don't go on a library-widerampage of wholesale conversions. The time to start using the newformatting is when writing new modules or packages, or possibly whendoing a major refactoring/upgrade of an existing module or package.One thing I'd like to see happening regardless is support fornew-style formatting in the logging module. It's a little tricky tothink how that would work, alas -- should this be a property of thelogger or of the call?-- --Guido van Rossum (python.org/~guido)


More information about the Python-Devmailing list

[8]ページ先頭

©2009-2025 Movatter.jp