Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder2.hal-mli.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'valueerror:': 0.09; '-tkc': 0.16; '2.6,': 0.16; 'benjamin': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'message- id:@tim.thechases.com': 0.16; 'received:70.251': 0.16; 'received:dsl.rcsntx.swbell.net': 0.16; 'received:rcsntx.swbell.net': 0.16; 'received:swbell.net': 0.16; 'subject:vs.': 0.16; '{}"': 0.16; 'cc:addr:python-list': 0.16; 'syntax': 0.16; 'wrote:': 0.18; '>>>': 0.18; '(most': 0.21; "doesn't": 0.22; 'header:In-Reply-To:1': 0.22; 'versions': 0.23; 'debian': 0.23; 'string': 0.24; 'cc:2**0': 0.24; 'traceback': 0.24; 'cc:addr:python.org': 0.29; 'skip:p 30': 0.29; 'quite': 0.32; 'earlier': 0.32; 'header:User-Agent:1': 0.33; 'last):': 0.34; 'file': 0.36; 'class.': 0.37; 'some': 0.38; 'below': 0.63 Date: Sat, 31 Dec 2011 13:24:10 -0600 From: Tim Chase User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111120 Icedove/3.1.16 MIME-Version: 1.0 To: Benjamin Kaplan Subject: Re: .format vs. % References: <5642862.375.1325355574622.JavaMail.geo-discussion-forums@vbbhx10> <3779937.289.1325357048110.JavaMail.geo-discussion-forums@vbtv37> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - boston.accountservergroup.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tim.thechases.com X-Source: X-Source-Args: X-Source-Dir: Cc: "python-list@python.org" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1325359459 news.xs4all.nl 6871 [2001:888:2000:d::a6]:40750 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:18269 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 "", line 1, in ValueError: zero length field name in format It needs to be spelled "{0}" -tkc