From: Skip Montanaro Date: Sun, 21 Mar 2004 16:05:30 +0000 (+0000) Subject: concrete example of why retaining old objects is good X-Git-Tag: v2.4a1~642 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=20a8336ff76baeed972dfc2c559615ef4f2a50b2;p=python concrete example of why retaining old objects is good --- diff --git a/Doc/lib/libfuncs.tex b/Doc/lib/libfuncs.tex index a96fe49cbb..f596cecc02 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},