Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeder2.enfer-du-nord.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!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.012 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; "wouldn't": 0.03; 'interpreter': 0.05; 'python': 0.09; 'subject:string': 0.09; 'sure,': 0.09; 'cc:addr:python-list': 0.10; 'subject:python': 0.11; 'bit.': 0.16; 'general.': 0.16; 'objection': 0.16; 'yingjie': 0.16; 'changes': 0.19; 'string': 0.19; 'wrote:': 0.19; 'import': 0.20; 'header:In-Reply-To:1': 0.22; 'bit': 0.22; 'suggested': 0.23; 'cc:2**0': 0.26; 'header:User-Agent:1': 0.26; 'function': 0.26; 'gets': 0.27; 'cc:addr:python.org': 0.28; '*this': 0.28; 'steven': 0.28; 'subject:skip:i 10': 0.28; 'there.': 0.28; 'suggestion': 0.31; 'format,': 0.32; 'could': 0.32; 'pm,': 0.34; 'add': 0.34; 'version': 0.34; 'things': 0.35; 'should': 0.35; 'does': 0.36; 'doing': 0.36; 'calling': 0.36; 'languages': 0.36; 'pretty': 0.36; 'skip:d 20': 0.36; 'easily': 0.36; 'but': 0.37; 'say': 0.37; 'why': 0.37; 'dynamic': 0.37; 'subject:: ': 0.37; 'instead': 0.38; 'anything': 0.38; 'old': 0.38; 'some': 0.39; 'too': 0.39; 'someone': 0.40; "won't": 0.40; 'hoping': 0.72; 'as:': 0.75; 'viewed': 0.78; 'to:addr:yahoo.com': 0.82; 'locals': 0.84; 'this...': 0.84; 'procedure,': 0.91 Date: Mon, 02 Apr 2012 15:36:04 -0500 From: Evan Driscoll User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10 MIME-Version: 1.0 To: Yingjie Lan Subject: Re: Re: string interpolation for python References: <1333174946.18436.YahooMailNeo@web121506.mail.ne1.yahoo.com> <4f7962b0$0$29981$c3e8da3$5496439d@news.astraweb.com> <4f79938c$0$29981$c3e8da3$5496439d@news.astraweb.com> <1333376732.8379.YahooMailNeo@web121502.mail.ne1.yahoo.com> In-Reply-To: <1333376732.8379.YahooMailNeo@web121502.mail.ne1.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Seen-By: mailfromd 4.1 sandstone.cs.wisc.edu Cc: "python-list@python.org" 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: 2001:888:2000:d::a6 X-Trace: 1333398975 news.xs4all.nl 6844 [2001:888:2000:d::a6]:41756 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:22537 On 01/-10/-28163 01:59 PM, Yingjie Lan wrote: > Because of the d"..." format, it won't > affect old ways of doing things one bit. > Allowing dynamic string wouldn't hurt > a bit to anything that is already there. Why don't you just write a function that does it? I think someone already suggested this... import dynamic_strings # write this d = dynamic_strings.dynamic x = 5 print(d("x=$x$")) ? Sure, it's not *quite* as pretty as if you could just say d"x=$x$", and you might have to do some hacky uglyness in the implementation to get at the locals of the calling procedure, but it solves a bazillion problems, such as: 1. YOU can do it, instead of hoping it gets into the mainline interpreter 2. You can do it NOW, and it will work with "any" version of Python 3. You have the freedom to easily add "eval from *this dictionary* if you want, which solves Steven D'Aprano's objection that your suggestion is too weak. 4. Languages changes should be viewed suspiciously in general. Evan