embed data inside string
Martin v. Loewis
martin at v.loewis.de
Thu May 16 02:18:00 EDT 2002
Julia Bell <juliabell at sbcglobal.net> writes:
> (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.
The Python equivalent of this is
mystring = "Value of parameter = %s is unexpected" % parameter
I'm not sure why you would consider this less simple than what you
originally had, or than the Perl version.
Regards,
Martin
More information about the Python-list
mailing list