Text of docs.python.org › 3.16 › library › idle.html as Styx crawled it on Oct 8, 2026. The page may have changed since. Only its words are kept, without pictures or layout, and only the first part of a long page.

Open the live page

IDLE — Python editor and shell — Python 3.16.0a0 documentation

Navigation index modules | next | previous | Python » 3.16.0a0 Documentation » The Python standard library » Graphical user interfaces with Tk » IDLE — Python editor and shell | Theme | IDLE — Python editor and shell ¶ Source code: Lib/idlelib/ IDLE is Python’s Integrated Development and Learning Environment. IDLE has the following features: cross-platform: works mostly the same on Windows, Unix, and macOS Python shell window (interactive interpreter) with colorizing of code input, output, and error messages multi-window text editor with multiple undo, Python colorizing, smart indent, call tips, auto completion, and other features search within any window, replace within editor windows, and search through multiple files (grep) debugger with persistent breakpoints, stepping, and viewing of global and local namespaces configuration, browsers, and other dialogs The IDLE application is implemented in the idlelib package.

This is an optional module . If it is missing from your copy of CPython, look for documentation from your distributor (that is, whoever provided Python to you). If you are the distributor, see Requirements for optional modules . Menus ¶ IDLE has two main window types, the Shell window and the Editor window. It is possible to have multiple editor windows simultaneously. On Windows and Linux, each has its own top menu.

Each menu documented below indicates which window type it is associated with. Output windows, such as used for Edit => Find in Files, are a subtype of editor window. They currently have the same top menu but a different default title and context menu. On macOS, there is one application menu. It dynamically changes according to the window currently selected. It has an IDLE menu, and some entries described below are moved around to conform to Apple guidelines.

File menu (Shell and Editor) ¶ New File Create a new file editing window. Open… Open an existing file with an Open dialog. Open Module… Open an existing module (searches sys.path). Recent Files Open a list of recent files. Click one to open it. Module Browser Show functions, classes, and methods in the current Editor file in a tree structure. In the shell, open a module first. Path Browser Show sys.path directories, modules, functions, classes and methods in a tree structure.

Save Save the current window to the associated file, if there is one. Windows that have been changed since being opened or last saved have a * before and after the window title. If there is no associated file, do Save As instead. Save As… Save the current window with a Save As dialog. The file saved becomes the new associated file for the window. (If your file manager is set to hide extensions, the current extension will be omitted in the file name box.

If the new filename has no ‘.’, ‘.py’ and ‘.txt’ will be added for Python and text files, except that on macOS Aqua,’.py’ is added for all files.) Save Copy As… Save the current window to different file without changing the associated file. (See Save As note above about filename extensions.) Print Window Print the current window to the default printer. Close Window Close the current window (if an unsaved editor, ask to save; if an unsaved Shell, ask to quit execution).

Calling exit() or close() in the Shell window also closes Shell. If this is the only window, also exit IDLE. Exit IDLE Close all windows and quit IDLE (ask to save unsaved edit windows). Edit menu (Shell and Editor) ¶ Undo Undo the last change to the current window. A maximum of 1000 changes may be undone. Redo Redo the last undone change to the current window. Select All Select the entire contents of the current window.

Cut Copy selection into the system-wide clipboard; then delete the selection. Copy Copy selection into the system-wide clipboard. Paste Insert contents of the system-wide clipboard into the current window. The clipboard functions are also available in context menus. Find… Open a search dialog with many options Find Again Repeat the last search, if there is one. Find Selection Search for the currently selected string, if there is one.

Find in Files… Open a file search dialog. Put results in a new output window. Replace… Open a search-and-replace dialog. Go to Line Move the cursor to the beginning of the line requested and make that line visible. A request past the end of the file goes to the end. Clear any selection and update the line and column status. Show Completions Open a scrollable list allowing selection of existing names. See Completions in the Editing and Navigation section below.

Expand Word Expand a prefix you have typed to match a full word in the same window; repeat to get a different expansion. Show Call Tip After an unclosed parenthesis for a function, open a small window with function parameter hints. See Calltips in the Editing and Navigation section below. Show Surrounding Parens Highlight the surrounding parenthesis. Format menu (Editor window only) ¶ Format Paragraph Rewrap the text block containing the text insert cursor.

Avoid code lines. See Format block in the Editing and Navigation section below. Indent Region Shift selected lines right by the indent width (default 4 spaces). Dedent Region Shift selected lines left by the indent width (default 4 spaces). Comment Out Region Insert ## in front of selected lines. Uncomment Region Remove leading # or ## from selected lines. Tabify Region Turn leading stretches of spaces into tabs. (Note: We recommend using 4 space blocks to indent Python code.) Untabify Region Turn all tabs into the correct number of spaces.

Toggle Tabs Open a dialog to switch between indenting with spaces and tabs. New Indent Width Open a dialog to change indent width. The accepted default by the Python community is 4 spaces. Strip Trailing Whitespace Remove trailing space and other whitespace characters after the last non-whitespace character of a line by applying str.rstrip() to each line, including lines within multiline strings. Except for Shell windows, remove extra newlines at the end of the file.

Run menu (Editor window only) ¶ Run Module Do Check Module . If no error, restart the shell to clean the environment, then execute the module. Output is displayed in the Shell window. Note that output requires use of print or write . When execution is complete, the Shell retains focus and displays a prompt. At this point, one may interactively explore the result of execution. This is similar to executing a file with python -i file at a command line.

Run… Customized Same as Run Module , but run the module with customized settings. Command Line Arguments extend sys.argv as if passed on a command line. The module can be run in the Shell without restarting. Check Module Check the syntax of the module currently open in the Editor window. If the module has not been saved IDLE will either prompt the user to save or autosave, as selected in the General tab of the Idle Settings dialog.

If there is a syntax error, the approximate location is indicated in the Editor window. Python Shell Open or wake up the Python Shell window. Shell menu (Shell window only) ¶ View Last Restart Scroll the shell window to the last Shell restart. Restart Shell Restart the shell to clean the environment and reset display and exception handling. Previous History Cycle through earlier commands in history which match the current entry.

Next History Cycle through later commands in history which match the current entry. Interrupt Execution Stop a running program. Debug menu (Shell window only) ¶ Go to File/Line Look on the current line. with the cursor, and the line above for a filename and line number. If found, open the file if not already open, and show the line. Use this to view source lines referenced in an exception traceback and lines found by Find in Files.

Also available in the context menu of the Shell window and Output windows. Debugger (toggle) When activated, code entered in the Shell or run from an Edit

The rest of this page is on the live site.