embed data inside string
David K. Trudgett
dkt at registriesltd.com.au
Thu May 16 02:07:49 EDT 2002
On Thursday 2002-05-16 at 04:19:43 +0000, Julia Bell wrote:
> 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.)
The best way in Python would probably be:
mystring = "Value of parameter = %s is unexpected" % (parameter)
which, although a formatted string, looks pretty simple to me ;-)
David Trudgett
More information about the Python-list
mailing list