summaryrefslogtreecommitdiffstats
path: root/Doc/lib/libfuncs.tex
diff options
context:
space:
mode:
authorSkip Montanaro <skip@pobox.com>2004-03-21 16:05:30 (GMT)
committerSkip Montanaro <skip@pobox.com>2004-03-21 16:05:30 (GMT)
commit20a8336ff76baeed972dfc2c559615ef4f2a50b2 (patch)
tree9123680cf296f194df1a0670fd2881d5f3ee81b7 /Doc/lib/libfuncs.tex
parent347c30d217cc4c9b832bb34e0b8e65346f3877fe (diff)
downloadcpython-20a8336ff76baeed972dfc2c559615ef4f2a50b2.zip
cpython-20a8336ff76baeed972dfc2c559615ef4f2a50b2.tar.gz
cpython-20a8336ff76baeed972dfc2c559615ef4f2a50b2.tar.bz2
concrete example of why retaining old objects is good
Diffstat (limited to 'Doc/lib/libfuncs.tex')
-rw-r--r--Doc/lib/libfuncs.tex10
1 files changed, 9 insertions, 1 deletions
diff --git a/Doc/lib/libfuncs.tex b/Doc/lib/libfuncs.tex
index a96fe49..f596cec 100644
--- a/Doc/lib/libfuncs.tex
+++ b/Doc/lib/libfuncs.tex
@@ -830,7 +830,15 @@ class C(object):
old version, the old definition remains. This feature can be used
to the module's advantage if it maintains a global table or cache of
objects --- with a \keyword{try} statement it can test for the
- table's presence and skip its initialization if desired.
+ table's presence and skip its initialization if desired:
+
+\begin{verbatim}
+try:
+ cache
+except NameError:
+ cache = {}
+\end{verbatim}
+
It is legal though generally not very useful to reload built-in or
dynamically loaded modules, except for \refmodule{sys},