[Python-ideas] String interpolation for all literal strings

Dan Sommers dan at tombstonezero.net
Thu Aug 6 04:20:29 CEST 2015


On Thu, 06 Aug 2015 09:59:57 +1000, Chris Angelico wrote:

> Whether or not it's good for string literals to support interpolation,
> though, I'm not sure about. The idea that stuff should get
> interpolated into strings fits a shell scripting language perfectly,
> but I'm not fully convinced it's a good thing for an applications
> language ...

I had that same reaction:  string interpolation is a shell-scripty
thing.  That said, my shell has printf as a built in function, and my OS
comes with /usr/bin/printf whether I want it or not.

> ... How shelly is Python? Or, what other non-shell languages have this
> kind of feature? PHP does (which is hardly an advertisement!); I can't
> think of any others off hand, any pointers?

Ruby has this kind of feature.

Common Lisp's format string is an entire DSL, but that DSL is like
printf in that the string describes the formatting and the remaining
arguments to the format function provide the data, rather than the
string naming local variables or containing expressions to be evaluated.



More information about the Python-ideas mailing list