]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
#4671: document that pydoc imports modules.
authorGeorg Brandl <georg@python.org>
Sat, 27 Dec 2008 19:11:15 +0000 (19:11 +0000)
committerGeorg Brandl <georg@python.org>
Sat, 27 Dec 2008 19:11:15 +0000 (19:11 +0000)
Doc/library/pydoc.rst

index 6d4986e81c02921ffa62d40f1e7ed70049991637..37845154776c284fd6b41e28f6c7f047479c943d 100644 (file)
@@ -36,6 +36,13 @@ it contains the path separator for your operating system, such as a slash in
 Unix), and refers to an existing Python source file, then documentation is
 produced for that file.
 
+.. note::
+
+   In order to find objects and their documentation, :mod:`pydoc` imports the
+   module(s) to be documented.  Therefore, any code on module level will be
+   executed on that occasion.  Use an ``if __name__ == '__main__':`` guard to
+   only execute code when a file is invoked as a script and not just imported.
+
 Specifying a :option:`-w` flag before the argument will cause HTML documentation
 to be written out to a file in the current directory, instead of displaying text
 on the console.