string interpolation for python

Jussi Piitulainen jpiitula at ling.helsinki.fi
Mon Apr 2 04:01:18 EDT 2012


Yingjie Lan writes:

> Clearly dynamic strings are much more powerful,
> allowing arbitrary expressions inside. It is also
> more terse and readable, since we need no dictionary.
...
> On the implementation, I would suppose new 
> syntax is needed (though very small).

I don't think you need any new syntax to implement this.
You can use a syntax like Dynamite("Hello, $world$") now,
similar to fraction.Fraction:

>>> Fraction(3,4) + 1
Fraction(7, 4)

No special syntax there, yet it can be done.



More information about the Python-list mailing list