[Python-checkins] CVS: python/dist/src/Doc/lib libdoctest.tex,1.6,1.6.2.1
Fred L. Drake
fdrake@users.sourceforge.net
Mon, 11 Jun 2001 07:57:09 -0700
Update of /cvsroot/python/python/dist/src/Doc/lib
In directory usw-pr-cvs1:/tmp/cvs-serv28910
Modified Files:
Tag: release21-maint
libdoctest.tex
Log Message:
Merge in recent changes from development branch: add warning about being
sure that code only runs once when using the module as both a module and a
script.
Index: libdoctest.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdoctest.tex,v
retrieving revision 1.6
retrieving revision 1.6.2.1
diff -C2 -r1.6 -r1.6.2.1
*** libdoctest.tex 2001/04/05 18:31:27 1.6
--- libdoctest.tex 2001/06/11 14:57:07 1.6.2.1
***************
*** 407,410 ****
--- 407,421 ----
Simple fractions are also easier for people to understand, and that makes
for better documentation.
+
+ \item Be careful if you have code that must only execute once.
+
+ If you have module-level code that must only execute once, a more foolproof
+ definition of \function{_test()} is
+
+ \begin{verbatim}
+ def _test():
+ import doctest, sys
+ doctest.testmod(sys.modules["__main__"])
+ \end{verbatim}
\end{enumerate}