Question about quoting style.

Carsten Haese carsten at uniqsys.com
Mon Oct 1 19:40:25 EDT 2007


On Mon, 2007-10-01 at 15:10 -0700, James Stroud wrote:
> Bruno Desthuilliers wrote:
> > First point is that Python has no "variable interpolation".
> 
> If you squint, it kind of does*:
> 
>     >>> print '%(language)s has %(#)03d quote types.' % \
>               {'language': "Python", "#": 2}
>     Python has 002 quote types.
> 
> You might think if the dict as a name space and the formatting operation 
> as performing interpolation--but this take on formatting might be a stretch.

It looks even more like interpolation if you do it like this:

>>> language = "Python"
>>> num = 2
>>> print '%(language)s has %(num)03d quote types.' % locals()
Python has 002 quote types.

-- 
Carsten Haese
http://informixdb.sourceforge.net





More information about the Python-list mailing list