summaryrefslogtreecommitdiffstats
path: root/Doc/whatsnew/whatsnew24.tex
diff options
context:
space:
mode:
authorAndrew M. Kuchling <amk@amk.ca>2004-09-10 11:34:39 (GMT)
committerAndrew M. Kuchling <amk@amk.ca>2004-09-10 11:34:39 (GMT)
commita79ec22f9fee81898f98d3109d57e2296d2b5fe3 (patch)
treeffb3f7044f0dbf43b1f81ab934d6040f57efc5cb /Doc/whatsnew/whatsnew24.tex
parentdff68d0ceda14823bd6f030edd91a7f11eb4bd96 (diff)
downloadcpython-a79ec22f9fee81898f98d3109d57e2296d2b5fe3.zip
cpython-a79ec22f9fee81898f98d3109d57e2296d2b5fe3.tar.gz
cpython-a79ec22f9fee81898f98d3109d57e2296d2b5fe3.tar.bz2
Update PEP292 section
Diffstat (limited to 'Doc/whatsnew/whatsnew24.tex')
-rw-r--r--Doc/whatsnew/whatsnew24.tex15
1 files changed, 5 insertions, 10 deletions
diff --git a/Doc/whatsnew/whatsnew24.tex b/Doc/whatsnew/whatsnew24.tex
index d1d316e..4570b2d 100644
--- a/Doc/whatsnew/whatsnew24.tex
+++ b/Doc/whatsnew/whatsnew24.tex
@@ -213,27 +213,22 @@ Unicode string:
\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.}