Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.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.020 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'python': 0.07; '%s"': 0.09; 'subject:string': 0.09; 'to:name:python mailing list': 0.09; 'subject:formatting': 0.16; '{0}': 0.16; 'skip:{ 10': 0.23; 'preferred': 0.26; 'message-id:@mail.gmail.com': 0.28; '"the': 0.28; 'string': 0.29; 'hi,': 0.29; 'received:209.85.210.46': 0.31; 'received:mail-pz0-f46.google.com': 0.31; 'style.': 0.31; 'to:addr :python-list': 0.32; 'should': 0.37; 'received:209.85': 0.37; 'received:google.com': 0.38; 'but': 0.38; 'to:addr:python.org': 0.39; 'received:209': 0.39; 'header:Received:5': 0.40; '(3)': 0.64 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:from:date:message-id:subject:to :content-type; bh=H5HSb6t2voc+ZDzqCJqwM3pccB8Z1W7/NZUZrwP/SCM=; b=wPiV/iIth2UHdozmeF0SwdTmigMiMqVAFDNj2+1B4+Yp+bi9bm32laLySoFunQMVGR u9dwpLCD8zXn4KGsDkIFN1dJp5ECpIiXc5yX0XrS/kVUbGjrxRvHB+hiXQ53loAJCLl8 VieqfzCpDPOvZm8xK+vKq3vOObWtXlfq0XzOY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; b=Q0OCYBs4ydYuy3+4ILHyW38wEgB0GVzl7g8JsTS4wZ1NiRb2+Li/1PRCemZAA1ARYM FAQZTjtiGmnHtxoqXtGiWw6fvLMm+GWyihtrbC9ecurWKDAHH9r7mkKZa6MzA/XAGcSO MnHMUxDR3Mp/HZ+6/BXs83smwoLAllnVSKAXI= MIME-Version: 1.0 From: Jabba Laci Date: Fri, 6 May 2011 03:18:17 -0400 Subject: string formatting To: Python mailing list Content-Type: text/plain; charset=ISO-8859-1 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: 16 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1304666321 news.xs4all.nl 34849 [::ffff:82.94.164.166]:60588 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:4802 Hi, Which is the preferred way of string formatting? (1) "the %s is %s" % ('sky', 'blue') (2) "the {0} is {1}".format('sky', 'blue') (3) "the {} is {}".format('sky', 'blue') As I know (1) is old style. (2) and (3) are new but (3) is only supported from Python 2.7+. Which one should be used? Laszlo