On 12/31/11 12:57, Benjamin Kaplan wrote:
format is a method of the string class. You store the string the same way
you would any other.

formatter = "Hello, {}"
print(formatter.format("world"))

Just to note that this syntax doesn't quite work in some earlier versions (tested below in 2.6, which came stock in Debian Stable)

>>> formatter = "Hello, {}"
>>> print(formatter.format("world"))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: zero length field name in format


It needs to be spelled "{0}"

-tkc


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to