Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!tudelft.nl!txtfeed1.tudelft.nl!multikabel.net!newsfeed10.multikabel.net!xlned.com!feeder7.xlned.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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'anyway.': 0.05; 'issue,': 0.05; 'things.': 0.05; 'assignment': 0.07; 'correct.': 0.07; 'expressions': 0.07; 'new,': 0.07; 'ok.': 0.07; 'python': 0.09; '>>>>': 0.09; 'computed': 0.09; 'formatting': 0.09; 'subject:string': 0.09; 'sure,': 0.09; 'type,': 0.09; 'subject:python': 0.11; 'equivalent': 0.12; 'itself.': 0.12; '>>>': 0.14; 'to:name:python-list@python.org': 0.14; '"are': 0.16; '"well,': 0.16; '(and,': 0.16; 'eval': 0.16; 'expressions,': 0.16; 'expressions.': 0.16; 'from:addr:lanyjie': 0.16; 'from:name:yingjie lan': 0.16; 'magic': 0.16; 'need:': 0.16; 'notation,': 0.16; 'perfect.': 0.16; 'received:124.205': 0.16; 'reply-to:addr:lanyjie': 0.16; 'reply-to:name:yingjie lan': 0.16; 'substitute': 0.16; 'syntactic': 0.16; 'syntax,': 0.16; 'yingjie': 0.16; 'comparing': 0.17; 'string,': 0.17; 'allows': 0.20; 'latter': 0.21; 'skip:% 10': 0.21; 'header:In-Reply-To:1': 0.22; 'demonstrate': 0.23; 'issue.': 0.23; 'hey': 0.23; 'cheers,': 0.26; 'realize': 0.26; 'sequence': 0.27; 'concern': 0.28; 'now?': 0.28; 'proposing': 0.28; 'subject:skip:i 10': 0.28; 'all.': 0.28; 'reply-to:addr:yahoo.com': 0.28; 'especially': 0.28; 'supported': 0.30; 'skip:b 20': 0.30; 'knows': 0.31; 'massive': 0.34; 'to:addr :python-list': 0.35; 'things': 0.35; 'there': 0.36; 'does': 0.36; 'another': 0.36; '(with': 0.36; 'languages': 0.36; 'being': 0.36; 'but': 0.37; 'community': 0.37; 'far': 0.37; 'say': 0.37; 'why': 0.37; 'dynamic': 0.37; 'subject:: ': 0.37; 'issues': 0.38; 'old': 0.38; 'to:addr:python.org': 0.39; 'sure': 0.40; 'allow': 0.40; '8bit%:8': 0.40; 'quite': 0.40; "won't": 0.40; 'more.': 0.61; 'evaluate': 0.62; 'is.': 0.62; 'more': 0.63; 'header:Reply-To:1': 0.67; 'friendly': 0.68; 'business.': 0.79; 'absolutely': 0.84; ':).': 0.84; 'defensive': 0.84; 'differences,': 0.84; 'everything.': 0.84; 'hostile': 0.84; 'personally.': 0.84; 'spite': 0.84; 'careful': 0.91; 'received:98.138.90.53': 0.91 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 608768.58754.bm@omp1048.mail.ne1.yahoo.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1333367201; bh=VwwbkidIuqWdLMIif7Fo0PkIieomaVJJiG3fuSRjXrg=; h=X-YMail-OSG:Received:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=OrtEy2JK85+zr7Rp4cNO0HHhvx1TZkn1ITfVfgaP2JggRf7ezMVo69tWr9e4MeX1MCMA0pmwavLEphpoPiygLZmW83qTI9WBVMigoHSJdLLoNVDvHlmzhMH02Z62HzlTWe3rZDodr+bqft91xoTCJ+IDv/OPWEMXygzWllvY3bg= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=O/dNgRcGVLDCAvIdSPrzWsSZy2qyZUKvPZexDBDGoHjK93MZIiysjSNmNRda4cFaWhohGPdlpmhIQgJXOJzmOkNIzV7UJoNWCRCQ2216uNCFTGQwbYx/nRJhbpsA5DdONIJu+mexQ1WxZI4aDt7HLPh/teB0JdoY/xArotVlU8A=; X-YMail-OSG: KXUWadIVM1kwlZ8F1i8bxpBL69owpa9qLvsC5NpzUJW.kdG 9Cddam13i1175XCFRe2918IF8S8PGDoBr7t4HZup9Ccj9lxOH_uyqGvBEKtJ KjHkyjQ3pG5qPDMerRXy_nYpjX9CxDJGVPS5xDZ7rHNvyISGi5khZmVZwslt LQBpqPwd8QRl_Iop82nGjRvk6Tw8E7Bey5ss_3rmWkjW36FVtCFpxuiVCCl2 hwgVkYkNj3sQQMujIq1rtoOF2.bT9HKgjFjHpt5gjsw4nOrT0ipEbix7qfjJ 5B52ooxrx1c0Y7psAKV3BVzpZ9BQTkHApkJ7TAW5foWZrhCApBfW2gcZgv1v Whrl8DUWCZ1v2okKPouXKmmTWN.jt2VYllmZsuDnCh8BWk6GfYCPQjskOZ3J ldBlwzVxCVaad7G0ig40eyMhsaYAy4jpx4S_M84f.CDQ6MugOjKzOw_AcH3b VEdvcjLgE0HgHqrp.nXIsxA0- X-Mailer: YahooMailWebService/0.8.117.340979 References: <1333174946.18436.YahooMailNeo@web121506.mail.ne1.yahoo.com> <4f7962b0$0$29981$c3e8da3$5496439d@news.astraweb.com> <1333357906.6147.YahooMailNeo@web121503.mail.ne1.yahoo.com> Date: Mon, 2 Apr 2012 04:46:41 -0700 (PDT) From: Yingjie Lan Subject: Re: string interpolation for python To: "python-list@python.org" In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: Yingjie Lan 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: 33 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1333367209 news.xs4all.nl 6920 [2001:888:2000:d::a6]:55752 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:22459 >=A0=0A=0A>>>> "Are you "+name+"?"=0A> =0A> That allows arbitrary expressi= ons and everything.=0A>=A0=0A=0ATo make that work for any type, you need:= =0A=0A>>> "Are you "+ str(name) + "?"=0A=0AAnother concern is performance.= =0A=0AYou are absolutely right, they are=A0=0Aequivalent in that both are e= xpressions.=0AAs long as people start to realize that=0Adynamic strings are= expressions,=0Athere is no magic in it any more.=0A=0AAnd allowing express= ions in those=0Adynamic strings=A0would make sense=A0=0Asince=A0they are of= the same sort.=0A=0A>>> d"sin($x$) =3D $ sin(x):0.3f $"=0A=0Ais equivalent= to the expression of=0A=0A>>> "sin(%s"%x + ")=3D %0.3f"%sin(x)=0A=0ACompar= ing th e two, I would say the latter=0Ais more computer friendly while=A0= =0Athe former, more human friendly.=0A=0AIf the computed result is only to = be=0Aused in formatting the string, it would=0Abe nice to save an assignmen= t stmt.=0A=0A=0A>> =0A>> Almost as terse, but not as readable, especially= =0A>> when there are many=A0parts to substitute --=0A>> the coder and rea= der need to be careful=0A>> to=A0make sure the sequence is correct.=0A> = =0A> I quite like this notation, personally. It's convenient, and is=0A> su= pported (with variants) in quite a few C-derived languages (and, in=0A> spi= te of the massive syntactic differences, Python does have C=0A> heritage).= =0A=0ASure, once you get used to it, it would be harder to stop it=0A=A0the= harder it is :). That's part of human nature, anyway.=0A=0A=0A>> Why the = Python community is so=0A>> hostile to new things now?=0A>> Python has me= rits,=0A>> but it is far from being perfect.=0A> =0A> Hey now, no need to = get defensive :) Thing is, it's up to you to=0A> demonstrate that your prop= osal justifies itself. You're proposing to=0A> create a massive backward-co= mpatibility issue, so you need to prove=0A> that your new way of formatting= strings is sufficiently awesome to be=0A> able to say "Well, you need Pyth= on 3.4+ to use this".=0A> =0A=0A=0AOK. I have put it out as is. I trust peo= ple knows good things.=0A=0AI would simply say: this new way is much more s= imple=A0=0Aand much more powerful. And there is no security issues=0Aas lon= g as you don't use the evil eval to evaluate expressions,=0Awhich is always= a security issue.=0A=0AIt is new, and has no compatibility issues with old= ways at all.=0AIn syntax, all you need is to allow d"...", which clearly w= on't=0Aaffect any old ways of business.=0A=0ACheers,=0A=0AYingjie