[Python-Dev] transitioning from % to {} formatting (original) (raw)
Steven Bethard steven.bethard at gmail.com
Fri Oct 2 22:50:36 CEST 2009
- Previous message: [Python-Dev] transitioning from % to {} formatting
- Next message: [Python-Dev] transitioning from % to {} formatting
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Fri, Oct 2, 2009 at 12:43 PM, Martin Geisler <mg at lazybytes.net> wrote:
I hate calling methods on string literals, I think it looks very odd to have code like this:
"Displaying {0} of {1} revisions".format(x, y) Will we be able to write this as "Displaying {0} of {1} revisions" % (x, y) too?
I doubt it. One of the major complaints about the %-style formatting was that the use of % produced (somewhat) unexpected errors because of how operator precedence works::
'{0}'.format(4 + 1) '5' '%s' % 4 + 1 Traceback (most recent call last): File "", line 1, in TypeError: cannot concatenate 'str' and 'int' objects
Steve
Where did you get that preposterous hypothesis? Did Steve tell you that? --- The Hiphopopotamus
- Previous message: [Python-Dev] transitioning from % to {} formatting
- Next message: [Python-Dev] transitioning from % to {} formatting
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]