Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #22537
| Date | 2012-04-02 15:36 -0500 |
|---|---|
| From | Evan Driscoll <driscoll@cs.wisc.edu> |
| Subject | Re: Re: string interpolation for python |
| References | (6 earlier) <mailman.1205.1333358032.3037.python-list@python.org> <4f79938c$0$29981$c3e8da3$5496439d@news.astraweb.com> <mailman.1212.1333370596.3037.python-list@python.org> <jlc8b8$fu8$1@news.univ-fcomte.fr> <1333376732.8379.YahooMailNeo@web121502.mail.ne1.yahoo.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1232.1333398974.3037.python-list@python.org> (permalink) |
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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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