[Tutor] Perl Symbology (was: Are you allowed to shoot camels?)

Bill Mill bill.mill at gmail.com
Thu Feb 10 16:46:43 CET 2005


Sorry for the double post; I forgot one thing:

On Thu, 10 Feb 2005 10:43:28 -0500, Bill Mill <bill.mill at gmail.com> wrote:
> Jeff,
> 
> I get the impression that many pythonistas don't like string
> interpolation. I've never seen a clear definition of why. Anyway, it's
> easy enough to add with the Itpl [1] module:
> 
> >>> import Itpl, sys
> >>> sys.stdout = Itpl.filter()
> >>> s, n, r = 0, 0, 0
> >>> print "$s $n $r"
> 0 0 0
> >>> x = Itpl.itpl("$s $n $r")
> >>> x
> '0 0 0'
> 

This works with arbitrary data types too, to be truer to your example:

>>> s, n, r = '0', 12, 3.4
>>> x = Itpl.itpl("$s $n $r")
>>> x
'0 12 3.4'

Peace
Bill Mill
bill.mill at gmail.com


More information about the Tutor mailing list