Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
1dc98c44
Commit
1dc98c44
authored
Jun 08, 2001
by
Skip Montanaro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add warning about situation where code may be executed twice, once when
module is __main__ and once when module is imported.
parent
62f9d7c0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
0 deletions
+10
-0
Doc/lib/libdoctest.tex
Doc/lib/libdoctest.tex
+10
-0
No files found.
Doc/lib/libdoctest.tex
View file @
1dc98c44
...
...
@@ -408,6 +408,16 @@ Simple fractions are also easier for people to understand, and that makes
for better documentation.
\end{enumerate}
\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}
\subsection
{
Soapbox
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment