Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!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.025 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'host,': 0.09; 'imo.': 0.09; 'port,': 0.09; 'readable': 0.09; '>>>': 0.12; 'wrote:': 0.14; 'roy': 0.16; 'subject:syntax': 0.16; 'skip:" 40': 0.16; 'somewhere': 0.17; 'template': 0.19; 'seems': 0.21; "what's": 0.23; 'certainly': 0.25; 'string': 0.26; 'import': 0.29; 'opposed': 0.29; 'charset:iso-8859-15': 0.30; 'print': 0.31; 'to:addr:python-list': 0.33; "isn't": 0.33; 'php': 0.34; 'example,': 0.35; 'skip:" 10': 0.35; 'subject: ?': 0.35; 'subject:What': 0.35; 'quite': 0.36; 'similar': 0.37; 'something': 0.37; 'hello,': 0.38; 'subject:: ': 0.38; 'url:google': 0.38; 'easier': 0.39; 'to:addr:python.org': 0.39; 'more': 0.60; 'received:(helo localhost)': 0.73; 'subject:this': 0.76; 'received:ro': 0.93; 'url:80': 0.95 Date: Mon, 20 Jun 2011 10:18:45 +0300 From: Claudiu Popa X-Priority: 3 (Normal) To: python-list@python.org Subject: Re: What is this syntax ? MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable X-BitDefender-Spam: No (0) X-BitDefender-SpamStamp: v1, build 2.8.97.162796, SQMD Hits: InvalidIPBytes34 97.192.25.0, rbl score: 0(0), bayes score: 500(0), pbayes score: 500(0), neunet score: 0(0), flags: [NN_LEGIT_BITDEFENDER; NN_LEGIT_MAILING_LIST_TO], SQMD: 902184dc8ec383e7f373c4c01ff8f8bb.fuzzy.fzrbl.org, total: 0(775) X-BitDefender-Scanner: Clean, Agent: BitDefender qmail 3.1.0 on elfie.dsd.hq, sigver: 7.37967 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: 31 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1308554725 news.xs4all.nl 49180 [::ffff:82.94.164.166]:53235 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:8007 Hello, Isn't this similar to php interpolation? And quite readable imo. >>> import string >>> template =3D string.Template("$scheme://$host:$port/$route#$fragment") >>> template.substitute(scheme=3D"http", host=3D"google.com", port=3D"80", = route=3D"", fragment=3D"") 'http://google.com:80/#' >>> 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: >=20 > print "$scheme://$host:$port/$route#$fragment" >=20 > That certainly seems easier to me to read than: >=20 > print "%s://%s:%s/%s#%s" % (scheme, > port, > host, > route, > fragment) =20