embed data inside string

Julia Bell juliabell at sbcglobal.net
Thu May 16 00:19:43 EDT 2002


I can create a string from a mixture of quoted strings and data with
something like:
mystring = "Value of parameter = " + parameter + " is unexpected"
(where parameter is a variable holding a string value)
Is there a way to embed the VALUE of the parameter in the string from
within the quotes (essentially avoiding concatenating strings)?
(I don't want to use formatted strings - I'm looking for something to
simplify the line.)

In perl I would have used:
$mystring = "Value of parameter = $parameter is unexpected"
(inside double quotes, the $parameter variable is evaluated, and it's
value is embedded in the string)  I'm looking for something similar in
python where I can refer to the value of the parameter inside a string.

Julia Bell





More information about the Python-list mailing list