Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'string.': 0.04; '(especially': 0.07; 'compiler': 0.07; 'strings.': 0.07; 'formatting': 0.09; 'subject:string': 0.09; 'translations': 0.09; 'mon,': 0.11; 'subject:python': 0.11; '.py': 0.16; 'err,': 0.16; 'evaluating': 0.16; 'expression,': 0.16; 'formatting,': 0.16; 'formatting.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'necessary,': 0.16; 'suggesting': 0.16; 'yingjie': 0.16; 'code,': 0.19; 'string': 0.19; 'wrote:': 0.19; 'header:In-Reply-To:1': 0.22; 'message-id:@mail.gmail.com': 0.24; 'regular': 0.27; '-0700,': 0.28; "d'aprano": 0.28; 'efficiently': 0.28; 'steven': 0.28; 'strings,': 0.28; 'subject:skip:i 10': 0.28; 'convert': 0.28; 'received:209.85.210.174': 0.30; 'received:mail- iy0-f174.google.com': 0.30; 'received:209.85': 0.32; 'received:google.com': 0.32; 'file': 0.33; 'received:209.85.210': 0.33; 'turn': 0.33; 'pm,': 0.34; 'two': 0.35; 'to:addr:python- list': 0.35; 'received:209': 0.35; 'should': 0.35; 'there': 0.36; 'whatever': 0.36; 'but': 0.37; 'why': 0.37; 'dynamic': 0.37; 'subject:: ': 0.37; 'it.': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'stand': 0.60; '2012': 0.62; 'choose': 0.64; 'cut': 0.65; 'sounds': 0.71; 'actually,': 0.84; 'execution.': 0.84; 'hardly': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=z8rlMXLPptCYh/pjmUhkbYY1JjJBENdXc7VVdQeQZSY=; b=BR0womKK/2sDMKdonV+I7yMqBGE3bmU01UkjJehyDJiZDW5n6bchFislTlSE8JluY3 pTDp1VhYhrFJBWuna2DLh5n4rseMs5t45iV81OPqxSgev/4F/8MdnCZuTxxxqvYgjAIU veSFLzOMAHNrfGeMcpOPLLHHt4QWkDLCiwEGHWDMjHwwNtXBJHkMzFfyiBIkQzU04HNO kqw2u98NaJ371WGOUUEf7F2Fdhq6BCdWSZNaCybxKO5VVkSq5HWiquX77fIYBTuNTOS7 Q6nZYsH6ax3DMiXA1UrWgVlSMovbM2YcRNoX78mgEcnlNSxC6EHA3TkZ/dodU0KsD/Vr WHQQ== MIME-Version: 1.0 In-Reply-To: <4f7962b0$0$29981$c3e8da3$5496439d@news.astraweb.com> References: <1333174946.18436.YahooMailNeo@web121506.mail.ne1.yahoo.com> <4f7962b0$0$29981$c3e8da3$5496439d@news.astraweb.com> Date: Mon, 2 Apr 2012 18:47:19 +1000 Subject: Re: string interpolation for python From: Chris Angelico To: python-list@python.org 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 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: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1333356443 news.xs4all.nl 6892 [2001:888:2000:d::a6]:37792 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:22449 On Mon, Apr 2, 2012 at 6:26 PM, Steven D'Aprano wrote: > On Mon, 02 Apr 2012 00:39:42 -0700, Yingjie Lan wrote: >> The compiler can choose to convert it into a string >> formatting expression, of course. To efficiently format=A0strings at >> runtime, the best choice (especially >> for safty reasons) is string formatting, not evaluating a dynamic >> string. > > So you're suggesting that we should have dynamic strings, but not > actually use dynamic strings. The compiler should just convert them to > regular string formatting. > > Why not cut out the middle-man and just use regular string formatting? Actually, this sounds like a job for a precompiler/preprocessor. Do whatever translations you want on your code, then turn it into a .py file for execution. But hardly necessary, as there are already two - err, three, I stand corrected - perfectly good ways to do it. ChrisA