-

26.5. IDLE¶

+

IDLE¶

Source code: Lib/idlelib/


IDLE is Python’s Integrated Development and Learning Environment.

IDLE has the following features:

  • coded in 100% pure Python, using the tkinter GUI toolkit
  • -
  • cross-platform: works mostly the same on Windows, Unix, and Mac OS X
  • +
  • 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, @@ -107,16 +120,19 @@ of global and local namespaces
  • configuration, browsers, and other dialogs
-

26.5.2. Editing and navigation¶

+

Editing and navigation¶

+
+

Editor windows¶

+

IDLE may open editor windows when it starts, depending on settings +and how you start IDLE. Thereafter, use the File menu. There can be only +one open editor window for a given file.

+

The title bar contains the name of the file, the full path, and the version +of Python and IDLE running the window. The status bar contains the line +number (‘Ln’) and column number (‘Col’). Line numbers start with 1; +column numbers with 0.

+

IDLE assumes that files with a known .py* extension contain Python code +and that other files do not. Run Python code with the Run menu.

+
+
+

Key bindings¶

In this section, ‘C’ refers to the Control key on Windows and Unix and -the Command key on Mac OSX.

+the Command key on macOS.

  • Backspace deletes to the left; Del deletes to the right

  • @@ -395,8 +433,9 @@ this)

Standard keybindings (like C-c to copy and C-v to paste) may work. Keybindings are selected in the Configure IDLE dialog.

+
-

26.5.2.1. Automatic indentation¶

+

Automatic indentation¶

After a block-opening statement, the next line is indented by 4 spaces (in the Python Shell window by one tab). After certain keywords (break, return etc.) the next line is dedented. In leading indentation, Backspace deletes up @@ -406,7 +445,7 @@ are restricted to four spaces due to Tcl/Tk limitations.

See also the indent/dedent region commands in the edit menu.

-

26.5.2.2. Completions¶

+

Completions¶

Completions are supplied for functions, classes, and attributes of classes, both built-in and user-defined. Completions are also provided for filenames.

@@ -441,7 +480,7 @@ much can be found by default, e.g. the re module.

longer or disable the extension.

-

26.5.2.3. Calltips¶

+

Calltips¶

A calltip is shown when one types ( after the name of an accessible function. A name expression may include dots and subscripts. A calltip remains until it is clicked, the cursor is moved out of the argument area, @@ -464,7 +503,15 @@ might want to run a file after writing the import statements at the top, or immediately run an existing file before editing.

-

26.5.2.4. Python Shell window¶

+

Python Shell window¶

+

With IDLE’s Shell, one enters, edits, and recalls complete statements. +Most consoles and terminals only work with a single physical line at a time.

+

When one pastes code into Shell, it is not compiled and possibly executed +until one hits Return. One may edit pasted code first. +If one pastes more that one statement into Shell, the result will be a +SyntaxError when multiple statements are compiled as if they were one.

+

The editing features described in previous subsections work when entering +code interactively. IDLE’s Shell window also responds to the following keys.

  • C-c interrupts executing command

  • @@ -474,15 +521,15 @@ or immediately run an existing file before editing.

    Command history

    • Alt-p retrieves previous command matching what you have typed. On -OS X use C-p.
    • -
    • Alt-n retrieves next. On OS X use C-n.
    • +macOS use C-p. +
    • Alt-n retrieves next. On macOS use C-n.
    • Return while on any previous command retrieves that command
-

26.5.2.5. Text colors¶

+

Text colors¶

Idle defaults to black on white text, but colors text with special meanings. For the shell, these are shell output, shell error, user output, and user error. For Python code, at the shell prompt or in an editor, these are @@ -496,7 +543,7 @@ text in popups and dialogs is not user-configurable.

-

26.5.3. Startup and code execution¶

+

Startup and code execution¶

Upon startup with the -s option, IDLE will execute the file referenced by the environment variables IDLESTARTUP or PYTHONSTARTUP. IDLE first checks for IDLESTARTUP; if IDLESTARTUP is present the file @@ -510,7 +557,7 @@ looked for in the user’s home directory. Statements in this file will be executed in the Tk namespace, so this file is not useful for importing functions to be used from IDLE’s Python shell.

-

26.5.3.1. Command line usage¶

+

Command line usage¶

idle.py [-c command] [-d] [-e] [-h] [-i] [-r file] [-s] [-t title] [-] [arg] ...
 
 -c command  run command in the shell window
@@ -535,7 +582,7 @@ set in the Options dialog.