#4671: document that pydoc imports modules.

This commit is contained in:
Georg Brandl 2008-12-27 19:11:15 +00:00
parent 6b28f394a2
commit 1ffbfbc566
1 changed files with 7 additions and 0 deletions

View 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 Unix), and refers to an existing Python source file, then documentation is
produced for that file. 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 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 to be written out to a file in the current directory, instead of displaying text
on the console. on the console.