[Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.96, 1.97

akuchling at users.sourceforge.net akuchling at users.sourceforge.net
Fri Sep 10 13:34:42 CEST 2004


Update of /cvsroot/python/python/dist/src/Doc/whatsnew
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13429

Modified Files:
	whatsnew24.tex 
Log Message:
Update PEP292 section

Index: whatsnew24.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v
retrieving revision 1.96
retrieving revision 1.97
diff -u -d -r1.96 -r1.97
--- whatsnew24.tex	1 Sep 2004 04:05:08 -0000	1.96
+++ whatsnew24.tex	10 Sep 2004 11:34:39 -0000	1.97
@@ -213,27 +213,22 @@
 \begin{verbatim}
 >>> import string
 >>> t = string.Template('$page: $title')
->>> t % {'page':2, 'title': 'The Best of Times'}
+>>> t.substitute({'page':2, 'title': 'The Best of Times'})
 u'2: The Best of Times'
->>> t2 % {'cost':42.50, 'action':'polish'}
-u'$ 42.5: polishing'
 \end{verbatim}
 
 % $ Terminate $-mode for Emacs
 
-If a key is missing from the dictionary, the \class{Template} class 
-will raise a \exception{KeyError}.  There's also a \class{SafeTemplate}
-class that ignores missing keys:
+If a key is missing from the dictionary, the \method{substitute} method
+will raise a \exception{KeyError}.  There's also a \method{safe_substitute}
+method that ignores missing keys:
 
 \begin{verbatim}
 >>> t = string.SafeTemplate('$page: $title')
->>> t % {'page':3}
+>>> t.safe_substitute({'page':3})
 u'3: $title'
 \end{verbatim}
 
-Because templates are Unicode strings, you can use a template with the
-\module{gettext} module to look up translated versions of a message.
-
 \begin{seealso}
 \seepep{292}{Simpler String Substitutions}{Written and implemented 
 by Barry Warsaw.}



More information about the Python-checkins mailing list