[Python-Dev] converting the stdlib to str.format (original) (raw)
Paul Moore p.f.moore at gmail.com
Thu Jun 5 12:50:32 CEST 2008
- Previous message: [Python-Dev] converting the stdlib to str.format
- Next message: [Python-Dev] converting the stdlib to str.format
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 05/06/2008, Steven D'Aprano <steve at pearwood.info> wrote:
Yes, I don't particularly see the advantage of writing:
"spam %s spam" % (value,) over "spam %s spam" % value Why require the first version?
Because the second breaks if value is a tuple:
Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information.
value = (1,2) "spam %s spam" % value Traceback (most recent call last): File "", line 1, in TypeError: not all arguments converted during string formatting
Paul.
- Previous message: [Python-Dev] converting the stdlib to str.format
- Next message: [Python-Dev] converting the stdlib to str.format
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]