[Python-Dev] converting the stdlib to str.format (original) (raw)

Steven D'Aprano steve at pearwood.info
Wed Jun 4 16:19:10 CEST 2008


On Wed, 4 Jun 2008 11:28:40 pm Nick Coghlan wrote:

> Not to mention that e.g. "%r" % s is much simpler than > "{0!r}".format(s) (if I got the format spec right).

repr(s) is even simpler :)

Fair enough, and I see your smiley, but consider:

"X %r X" % s

"X {0!r} X".format(s)

"X " + repr(s) + " X"

I for one am excited to see advanced string formatting via .format(), but would be very disappointed if future Python versions removed the simplicity of %.

-- Steven



More information about the Python-Dev mailing list