On Wed, Sep 11, 2013 at 11:15:26AM +0100, Oscar Benjamin wrote:
> There is also the .format method. This was initially intended to
> replace % formatting but it was ultimately decided that removing %
> formatting was not necessary. Consequently there are now two ways of
> doing advanced string formatting in Python.
Three ways.
People forget the string.Template class.
py> import string
py> template = string.Template("Hello $name")
py> template.substitute(name="Oscar")
'Hello Oscar'
py> template.safe_substitute(nmae="Oscar")
'Hello $name'
--
Steven
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor