[Python-ideas] String interpolation again.

Andre Roberge andre.roberge at gmail.com
Fri Jul 23 18:03:05 CEST 2010


On Fri, Jul 23, 2010 at 11:16 AM, INADA Naoki <songofacandy at gmail.com>wrote:

> Basic problem is Python doesn't provide a way to print values of expression
> into str like print prints to file.
> 'foo{bar}baz'.format(bar=bar) is a bit bessy.
> ’foo{bar}baz'.format(**vars()) or other technique is a bit trickey and
> messy.
>
> If
>  s = 'foo' bar 'baz'
> is too dirty, another Pythonic way I think of are:
>
> [snip]

What's wrong with
s = 'foo' + str(bar) + 'baz'

If you want something Pythonic:

import this
...
Explicit is better than implicit

---
André
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20100723/0d8ef2c2/attachment.html>


More information about the Python-ideas mailing list