Popular recipes by Michael Strasser http://code.activestate.com/recipes/users/98134/2002-06-05T03:41:24-07:00ActiveState Code RecipesPrinting strings with embedded variable names (Python)
2002-06-05T03:41:24-07:00Michael Strasserhttp://code.activestate.com/recipes/users/98134/http://code.activestate.com/recipes/52290-printing-strings-with-embedded-variable-names/
<p style="color: grey">
Python
recipe 52290
by <a href="/recipes/users/98134/">Michael Strasser</a>
(<a href="/recipes/tags/text/">text</a>).
Revision 3.
</p>
<p>This class encapsulates a string with embedded variable names. They are usually evaluated when the object's __str__() method is called. You can specify that they be evaluated when the object is created by including the immediate argument to the constructor. The doc string at the top of the module has an example of its use.</p>
<p>Itamar Shtull-Trauring's printexpr.py inspired me to try this out.</p>