This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: pydoc executes the code to be documented
Type: behavior Stage:
Components: Documentation Versions: Python 2.6
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: Jim_C, georg.brandl, pitrou
Priority: normal Keywords:

Created on 2008-12-15 21:26 by Jim_C, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg77881 - (view) Author: Jim_C (Jim_C) Date: 2008-12-15 21:26
Running pydoc [ pydoc <modulename> ] on a python module using Tkinter 
displayed the window defined in the module - not what I was 
expecting..   Running pydoc on

from os import remove

will remove the file tmp.tmp, if it exists. 
If this behaviour is intentional ( as it appears to be, see 
imp.load_module ) & presumably integral to the operation of pydoc, then 
it might be worth providing a warning on the web page ( ) ?? 
Running a code with default arguments in an arbitrary directory could 
potentially produce unwanted side effects, at the very least..
Regards ,
msg77892 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2008-12-15 23:50
That's why you shouldn't put code with side effects at the root of a
module, but inside a "if __name__ == '__main__'" guard.

Anyway, it may be worth documenting it!
msg78382 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-12-27 19:11
Documented in r67963.
Date User Action Args
2022-04-11 14:56:42adminsetgithub: 48921
2008-12-27 19:11:31georg.brandlsetstatus: open -> closed
resolution: fixed
messages: + msg78382
2008-12-15 23:50:32pitrousetassignee: georg.brandl
messages: + msg77892
nosy: + georg.brandl, pitrou
components: + Documentation
versions: + Python 2.6, - Python 2.4
2008-12-15 21:26:07Jim_Ccreate