Variables escaping quotes

Mark McEahern marklists at
Tue Aug 20 01:41:44 CEST 2002

> Is there a way for a variable to escape quotation marks?  For example:
> x=10
> print "The husband only had $x minutes to live before his wife, in a rage
> of fury and wrath, would descend upon him like a thousand, shrieking
> banshees, to rend his life (not to mention his manhood) from his cowering
> body."
> where $x represents the number 10, not literally $x.

x = 10
print "The husband had only %d minutes to live..." % x

This is called string formatting in Python.

// m

More information about the Python-list mailing list