Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!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; 'from:addr:libero.it': 0.07; 'dict': 0.09; 'host,': 0.09; 'port,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:libero.it': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; '>>>': 0.12; 'wrote:': 0.14; 'roy': 0.16; 'specifier': 0.16; 'subject:syntax': 0.16; 'skip:" 40': 0.16; 'somewhere': 0.17; 'seems': 0.21; 'item.': 0.23; "what's": 0.23; 'certainly': 0.25; 'opposed': 0.29; 'print': 0.31; 'header:X -Complaints-To:1': 0.32; 'to:addr:python-list': 0.33; 'php': 0.34; 'example,': 0.35; 'header:User-Agent:1': 0.35; 'skip:" 10': 0.35; 'subject: ?': 0.35; 'subject:What': 0.35; 'something': 0.37; 'received:org': 0.38; 'data': 0.38; 'subject:: ': 0.38; 'easier': 0.39; 'header:Mime-Version:1': 0.39; 'to:addr:python.org': 0.39; 'format': 0.40; 'more': 0.60; 'received:151': 0.67; 'subject:this': 0.76 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Vito 'ZeD' De Tullio Subject: Re: What is this syntax ? Followup-To: gmane.comp.python.general Date: Sun, 19 Jun 2011 23:06:36 +0200 References: <4dfdfc99$0$715$426a34cc@news.free.fr> <4dfe10d1$0$28053$426a34cc@news.free.fr> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Gmane-NNTP-Posting-Host: ppp-14-21.26-151.libero.it User-Agent: KNode/4.4.11 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: 34 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1308517611 news.xs4all.nl 49039 [::ffff:82.94.164.166]:39576 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:7991 Roy Smith wrote: > There's something nice about building up strings in-line, as > opposed to having to look somewhere to see what's being interpolated. > To give a more complex example, consider: > > print "$scheme://$host:$port/$route#$fragment" > > That certainly seems easier to me to read than: > > print "%s://%s:%s/%s#%s" % (scheme, > port, > host, > route, > fragment) > > because I don't have to line up the nth format specifier with the nth > data item. well, in python3 you can use dict to format strings >>> print("%(a)s" % {'a':'b'}) b and you can achieve php interpolation via locals() >>> a = 'b' >>> print("%(a)s" % locals()) b -- By ZeD