string interpolation for python

Chris Rebert clp2 at rebertia.com
Sat Mar 31 09:51:50 CEST 2012


On Fri, Mar 30, 2012 at 11:22 PM, Yingjie Lan <lanyjie at yahoo.com> wrote:
> Hi all,
>
> I'd really like to share this idea of string interpolation for formatting.
> Let's start with some code:
>
>>>> name = "Shrek"
>>>> print( "Hi, $name$!")
> Hi, Shrek!

Python already has *3* different built-in string
formatting/interpolation systems:
http://docs.python.org/library/string.html#template-strings
http://docs.python.org/library/string.html#format-string-syntax
http://docs.python.org/library/stdtypes.html#string-formatting-operations
Do we really want to add yet another to this pile?

I would surmise that your key "implicitly grab variable values from
the enclosing scope" feature has previously been rejected for being
too magical.

Cheers,
Chris
--
http://rebertia.com



More information about the Python-list mailing list