Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #22461

Re: string interpolation for python

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!tudelft.nl!txtfeed1.tudelft.nl!feed.xsnews.nl!border-2.ams.xsnews.nl!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <lanyjie@yahoo.com>
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; 'method.': 0.05; 'compiler': 0.07; 'encouraging': 0.07; 'expressions': 0.07; 'subject:string': 0.09; 'cc:addr:python-list': 0.10; 'subject:python': 0.11; '"are': 0.16; 'expressions,': 0.16; 'from:addr:lanyjie': 0.16; 'from:name:yingjie lan': 0.16; 'hostile.': 0.16; 'partly': 0.16; 'personally,': 0.16; 'received:124.205': 0.16; 'received:98.138.89.199': 0.16; 'reply- to:addr:lanyjie': 0.16; 'reply-to:name:yingjie lan': 0.16; 'yingjie': 0.16; 'tend': 0.17; '(or': 0.18; 'url:02': 0.21; 'header:In-Reply-To:1': 0.22; 'variable': 0.23; 'towards': 0.24; 'cheers,': 0.26; 'cc:2**0': 0.26; 'cc:addr:python.org': 0.28; 'subject:skip:i 10': 0.28; 'reply-to:addr:yahoo.com': 0.28; "skip:' 10": 0.29; "can't": 0.32; 'like:': 0.32; 'probably': 0.32; 'could': 0.32; 'something': 0.34; 'url:org': 0.35; 'does': 0.36; 'calling': 0.36; 'easily': 0.36; 'but': 0.37; 'far': 0.37; 'subject:: ': 0.37; 'some': 0.39; 'quite': 0.40; 'more': 0.63; 'header:Reply-To:1': 0.67; 'url:2011': 0.72; 'conservative': 0.84; 'received:98.138.90.53': 0.91; 'enhancement': 0.93
X-Yahoo-Newman-Property ymail-3
X-Yahoo-Newman-Id 762450.21029.bm@omp1057.mail.ne1.yahoo.com
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1333368010; bh=qiFl1yW8hH3if0X+8+fqun5JqYUC7hTlsUg55V8lgOw=; h=X-YMail-OSG:Received:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=qurhjfBN37L/WUva2jLFFIHu54p4sxwxwVzSdF5gUo2hLJI8y6tZaGxoDC7EgSfmUNhinte0yBIHpRLNkzzOwUwo4mteiRxD1HlZ5E4Qux1615GPq0P8e9l7rd/H2fVfGsScNiOTnzritKp29MwV211lp8WBbMukeeIpn2f6/98=
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:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=k1HaJ9MGmb4cqsAKl/tYevBYOaTS/GujxOsHyntgzNRVrpipLfCVUo6Wyf98X0weVDrum6U+rkYxgnYdrZtI7+P7rWNwgRCpBdRzy6TmeTMFN3lZVtDQiPC594uNkRrHSO2Pr7CLaYBVoCAvBgbfEtED2YZKLEtcS3vbcQpvVsw=;
X-YMail-OSG .oSOZiEVM1n_Hecg1mqMckVmu4C8x1efmYVizWlF2fLz_nB Wv.ERFRYzNmvNRCMc6M8iBlPcoVxkP1QR13_qDqLj7qudjywznudwH5IrSf9 i9d_yoGHXcUm3YdCDjiHSQBx.g2QrQLBzQT34V3Jxqz.Lw1vyZaIqcJIGUE_ FihrWEEqp2fwFOt1VRm9clGq1pI34ijsqGih_6HgPD.7EZ_KvJ7yh83.ALtB jKg3ube54qtkwTDbWBOpacGTnsyU8fXM.7oJUnGJmKblohC2SXWIxFBru9Op FV7p68V9Pm_rys2aRKNV1aEo_dycWhtQxp6Y.zqvposhM9zlOlJQmuFNacvl 2u7smllL4AcB3aIK0rcB_ZI0Y8eR5yeqKeh9fL2gVSkyted7JCaC52l5b.yI imYmL7UA1OAYZgFVhJ7pWxtHna_IdFnPYX.JzlFhr7Wi8Kq7n59DSQzmUWQD C3gt._ryFIuYnSOSzrceqWOlpe6H.IL..dLu5egg9czklJtBS6Lely72x2K5 c0x5x2tsuW95aqYBH9R_r0XaNmfTE4L3r70O.W3uW4SC8CpcqfPMSrj25h5E pQW4e6s7aIuvXXNbYcjY2xodEqYsbmoRXqTbh1ek3RRYhAwyT7breuZO9.Gz Bm4GR8o35CxAh_gU2E3fO
X-Mailer YahooMailWebService/0.8.117.340979
References <CABgq=FyhR+Ldujj3YKRBpVXRVoeoayuXZviUUcNx-gXnFiHLSw@mail.gmail.com> <CACoeR0xV=28j6rFHm1ep3gzH9C0sbDqyxRRwX-JrVm3G+rrXww@mail.gmail.com> <1333174946.18436.YahooMailNeo@web121506.mail.ne1.yahoo.com> <jl6ma0$ptg$1@dough.gmane.org> <mailman.1200.1333352587.3037.python-list@python.org> <4f7962b0$0$29981$c3e8da3$5496439d@news.astraweb.com> <1333357906.6147.YahooMailNeo@web121503.mail.ne1.yahoo.com> <CAMZYqRRV-MT6we=8JgXjR4LSvofaR35DH9_6-ZEbag-hmSr11g@mail.gmail.com>
Date Mon, 2 Apr 2012 05:00:10 -0700 (PDT)
From Yingjie Lan <lanyjie@yahoo.com>
Subject Re: string interpolation for python
To Chris Rebert <clp2@rebertia.com>
In-Reply-To <CAMZYqRRV-MT6we=8JgXjR4LSvofaR35DH9_6-ZEbag-hmSr11g@mail.gmail.com>
MIME-Version 1.0
Content-Type text/plain; charset=iso-8859-1
Content-Transfer-Encoding quoted-printable
Cc "python-list@python.org" <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
Reply-To Yingjie Lan <lanyjie@yahoo.com>
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1211.1333368019.3037.python-list@python.org> (permalink)
Lines 14
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1333368019 news.xs4all.nl 6874 [2001:888:2000:d::a6]:36143
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:22461

Show key headers only | View raw


> "Are you %(name)s" % locals() # or vars()



This partly solves the problem, however, you 
can't work with expressions inside, like:

> d"sin($x$) = $sin(x)$"


Also, what if locals() or vars() does not contain
the variable "x"? (x could be nonlocal or global).


> It's more conservative than hostile. Here's some insight:
> http://www.boredomandlaziness.org/2011/02/status-quo-wins-stalemate.html
>

You are probably right...Harmless enhancement is still probable?


> 
> Personally, in isolation, the only part of your proposal I find
> /truly/ objectionable is the support for arbitrary expressions, since
> it would tend towards encouraging suboptimal factoring. But we also

I don't quite see that as a problem. The compiler (or translator, as you 
mentioned earlier) could easily make d"sin($x$) = $sin(x)$" into
something like: ''.join(["sin(", str(x), ") = ", str(sin(x))]
which would far more efficient than calling the format() method.

Cheers,
Yingjie

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: string interpolation for python Yingjie Lan <lanyjie@yahoo.com> - 2012-04-02 00:39 -0700
  Re: string interpolation for python Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2012-04-02 11:01 +0300
  Re: string interpolation for python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-04-02 08:26 +0000
    Re: string interpolation for python Chris Angelico <rosuav@gmail.com> - 2012-04-02 18:47 +1000
    Re: string interpolation for python Yingjie Lan <lanyjie@yahoo.com> - 2012-04-02 02:11 -0700
      Re: string interpolation for python Duncan Booth <duncan.booth@invalid.invalid> - 2012-04-02 10:19 +0000
      Re: string interpolation for python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-04-02 11:54 +0000
        Re: string interpolation for python Yingjie Lan <lanyjie@yahoo.com> - 2012-04-02 05:40 -0700
          Re: string interpolation for python Laurent Claessens <moky.math@gmail.com> - 2012-04-02 15:02 +0200
            Re: string interpolation for python Yingjie Lan <lanyjie@yahoo.com> - 2012-04-02 07:25 -0700
            Re: Re: string interpolation for python Evan Driscoll <driscoll@cs.wisc.edu> - 2012-04-02 15:36 -0500
          Re: string interpolation for python mwilson@the-wire.com - 2012-04-02 10:46 -0400
            Re: string interpolation for python mwilson@the-wire.com - 2012-04-02 11:34 -0400
              Re: string interpolation for python Yingjie Lan <lanyjie@yahoo.com> - 2012-04-02 09:02 -0700
      Re: string interpolation for python rusi <rustompmody@gmail.com> - 2012-04-02 06:04 -0700
    Re: string interpolation for python Yingjie Lan <lanyjie@yahoo.com> - 2012-04-02 02:17 -0700
      Re: string interpolation for python alex23 <wuwei23@gmail.com> - 2012-04-02 22:47 -0700
    Re: string interpolation for python Chris Angelico <rosuav@gmail.com> - 2012-04-02 19:56 +1000
    Re: string interpolation for python Chris Rebert <clp2@rebertia.com> - 2012-04-02 03:23 -0700
    Re: string interpolation for python Yingjie Lan <lanyjie@yahoo.com> - 2012-04-02 04:46 -0700
    Re: string interpolation for python Yingjie Lan <lanyjie@yahoo.com> - 2012-04-02 05:00 -0700
    Re: string interpolation for python Chris Angelico <rosuav@gmail.com> - 2012-04-03 00:58 +1000
      Re: string interpolation for python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-04-02 18:56 +0000
    Re: string interpolation for python Yingjie Lan <lanyjie@yahoo.com> - 2012-04-02 08:49 -0700
    Re: string interpolation for python Chris Angelico <rosuav@gmail.com> - 2012-04-03 08:38 +1000
      Re: string interpolation for python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-04-02 23:18 +0000
    Re: string interpolation for python Yingjie Lan <lanyjie@yahoo.com> - 2012-04-02 18:57 -0700

csiph-web