new string formatting with local variables

Steve Crook steve at mixmin.net
Mon Jun 6 14:30:17 EDT 2011


On Mon, 6 Jun 2011 12:15:35 -0400, Jabba Laci wrote in
Message-Id: <mailman.2490.1307376958.9059.python-list at python.org>:

> solo = 'Han Solo'
> jabba = 'Jabba the Hutt'
> print "{solo} was captured by {jabba}".format(solo=solo, jabba=jabba)
> # Han Solo was captured by Jabba the Hutt

How about:-

print "%s was captured by %s" % (solo, jabba)



More information about the Python-list mailing list