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


Groups > comp.lang.python > #22443

Re: string interpolation for python

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'string.': 0.04; 'syntax': 0.04; 'essentially': 0.05; '(especially': 0.07; 'compiler': 0.07; 'expressions': 0.07; 'suppose': 0.07; '>>>>': 0.09; 'formatting': 0.09; 'subject:string': 0.09; 'subject:python': 0.11; 'to:name :python-list@python.org': 0.14; 'balls': 0.16; 'dictionary.': 0.16; 'evaluating': 0.16; 'expression,': 0.16; 'from:addr:lanyjie': 0.16; 'from:name:yingjie lan': 0.16; 'readable': 0.16; 'received:124.205': 0.16; 'reply- to:addr:lanyjie': 0.16; 'reply-to:name:yingjie lan': 0.16; 'yingjie': 0.16; 'string': 0.19; 'header:In-Reply-To:1': 0.22; 'to:2**1': 0.25; 'efficiently': 0.28; 'received:98.138.87': 0.28; 'subject:skip:i 10': 0.28; 'convert': 0.28; 'reply- to:addr:yahoo.com': 0.28; 'skip:b 20': 0.30; 'probably': 0.32; 'code': 0.32; 'method': 0.33; 'rather': 0.33; 'mainly': 0.34; 'to:addr:python-list': 0.35; 'useful': 0.35; 'methods': 0.35; 'needed': 0.36; 'dynamic': 0.37; 'subject:: ': 0.37; 'to:addr:python.org': 0.39; '8bit%:8': 0.40; 'kind': 0.63; 'more': 0.63; 'choose': 0.64; 'header:Reply-To:1': 0.67; "'the": 0.91; 'have.': 0.91
X-Yahoo-Newman-Property ymail-3
X-Yahoo-Newman-Id 525114.38748.bm@omp1010.mail.ne1.yahoo.com
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1333352382; bh=YIzGArCoPh4kkjUL0IYvRjQG2ZOCzcXk/iK1ITGn2+8=; 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=cspvvnY9yfy5jz2fvlscGSiol67yDYjHYQWPtzQUN0tgpWhMJCe/yz+zrbJULHXPIouRoWuHunrF/gC/82LWzO/jY1HWb9q2TILZKAhx22kfAIpz9x/ctt5DAMlW+RYC+Pbh8fFtjlVCfAjZyQdGDjCv3EP2XrB0On6BfbHx+D4=
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=F5zgwYijIM/jQKlRkLrcIl324zz5njc7yn64tLfCMH0tcePbStLHC07C10YlUXEWY8UyQFffFRw/++IBYQs4s7lxSqHbL2XdTLK25RRZfjMzgp6cNYltQvFLjZy0T7YLB27OGR7diCC2t6urkL6mY8JKCl90bOWt73R4JgrYyus=;
X-YMail-OSG sFiImBwVM1n0UR4pfzZlgOH8fXi8.USadGjJZ6x5GFBb8.C TkmgwI.3cs5X8XRgPEGFn6pJPSidJ9snEoSZpMToFwcTCOnwolZQ8.DkQo_H IYIjoTarHFk931Xbpez5uhBWwkOwCc9soa_UReymKnFioumwYEHnFLLGsWBg KeeV7hPn1uCO9u1J5qI8z7fup_NSMns9.YOXA1jV8.Fad05moHfA.LnKLOg5 Jw.tdot0JtHKXa0L2Zo2OOnkRcbMuHOeJ9Ul2qcXyDtzyw4CJrN.9h3GZhIW i8qCSqa.uFXngqmJJNydctlpqmc30opaC0mnOIPyuq5kgu9bZigqDSHJms30 maBXEq70kpoFFlKywWOHoWeVBaDAodNPbwuF6PbYe0MK8F0fQBOMKN07XU.d Cm.XVF59sqsdpCUgIxugXWb1T6uhcKVmX3w_htMl7DY6tfCoCLT0TLg.S4Pp 8QYgmCt8qQPA62KaproNUToQ-
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>
Date Mon, 2 Apr 2012 00:39:42 -0700 (PDT)
From Yingjie Lan <lanyjie@yahoo.com>
Subject Re: string interpolation for python
To Terry Reedy <tjreedy@udel.edu>, "python-list@python.org" <python-list@python.org>
In-Reply-To <jl6ma0$ptg$1@dough.gmane.org>
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 <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.1200.1333352587.3037.python-list@python.org> (permalink)
Lines 16
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1333352587 news.xs4all.nl 6887 [2001:888:2000:d::a6]:42826
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:22443

Show key headers only | View raw


> You can already do essentially that without adding a special-case string 

> formatting method to the general methods we already have.
> 
>>>>  balls = 5
>>>>  people = 3
>>>>  'The {people} people have {balls} 
> balls.'.format(**locals())
> 'The 3 people have 5 balls.'


Clearly dynamic strings are much more powerful,
allowing arbitrary expressions inside. It is also
more terse and readable, since we need no dictionary.

I would probably rather liken dynamic expressions
as a little brother of computable documents in 
Mathematica. It is a new kind of expression,
rather than formatting -- though it has formatting
connections. 

Dynamic strings are mainly useful at time of
writing readable code before compilation. 
The compiler can choose to convert it into
a string formatting expression, of course.
To efficiently format strings at runtime, 
the best choice (especially
for safty reasons) is string formatting, 
not evaluating a dynamic string.

On the implementation, I would suppose new 
syntax is needed (though very small).

Yingjie

Back to comp.lang.python | Previous | NextNext 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