Python online course

Using the Python IDLE Editor

Learn how to open Python IDLE, use its Shell, create and save .py files, run modules, and use IDLE's beginner-friendly development tools.

What Is Python IDLE?

IDLE stands for Integrated Development and Learning Environment. It is Python's bundled, beginner-oriented development interface. IDLE is a free graphical application commonly included with a standard Python installation.

A GUI, or graphical user interface, is an application operated through windows, menus, buttons, and other visual controls. IDLE provides a GUI for several common Python tasks:

  • Entering and testing commands interactively
  • Creating and editing Python source files
  • Saving and running Python programs
  • Inspecting and diagnosing programs with basic debugging tools

IDLE itself is implemented in Python and uses Tkinter, Python's standard GUI toolkit. It is available on Windows, macOS, and Linux, although its menu names, launch location, and appearance can vary with the operating system and the way Python was installed.

IDLE is a lightweight way to learn Python fundamentals. As projects grow, you may prefer a more feature-rich editor or IDE, but the best tool depends on your project and personal workflow. IDLE remains useful for learning, experimentation, and small programs.

Shell and Editor Windows

IDLE normally uses two kinds of windows. The Python Shell is an interactive interpreter window: you enter Python commands and see their results immediately. An editor window is a text window for writing and saving multi-line Python source code.

Window | Primary use | What appears there

Shell window | Interactive commands | Commands, returned values, program output, and errors

Editor window | Multi-line source code | Python statements that can be edited and saved as scripts

Use the Shell for quick experiments, such as checking an expression. Use the editor for a reusable program. A script is a saved file containing Python statements, normally with a .py extension.

Key IDLE Features

  • Command history: previously entered Shell commands can be recalled instead of typed again.
  • Syntax highlighting: the editor uses colorization to distinguish Python keywords, strings, comments, and other code elements.
  • Automatic indentation: IDLE can indent and unindent Python code as you create blocks.
  • Word completion: autocomplete can suggest or complete names while you type.
  • Multiple windows: you can work with more than one Shell window or editor window.
  • Built-in debugger: IDLE includes basic tools for inspecting execution and diagnosing problems.

These conveniences do not replace learning Python syntax. They reduce typing and make the structure of code easier to see.

Starting IDLE

  1. Open your operating system's application menu or search feature.
  2. Search for IDLE. The entry may be named IDLE (Python 3.x) or include another Python version.
  3. Select the IDLE application to launch it.

On Windows, IDLE is commonly available from the Start menu or application search. On macOS, look in the Applications area or use system search. On Linux, use the desktop application menu or search. Exact locations and labels differ by operating system, Python version, and installation method.

When IDLE starts, its Shell window displays startup information. This information identifies the installed Python version and usually includes platform details. Checking the banner is a useful way to confirm which Python installation IDLE is using.

Using the IDLE Shell Interactively

The Shell window is an interactive Python interpreter. Its primary interactive prompt is shown as >>>. This marker means that the Shell is ready to receive a Python command.

For example, click after the prompt, enter an expression, and press Enter:

>>> 2 + 3
5

Python evaluates the expression immediately, and the result appears beneath the command. Output and error messages also appear in the Shell.

The Shell is useful for experimentation:

>>> name = "Ada"
>>> print("Hello, " + name)
Hello, Ada

Interactive commands are not the same as a reusable program file. You can recall commands with the Shell's command history, but a multi-line program typed into the Shell is difficult to edit and save as one unit. For reusable code, create an editor window and save the source as a script.

For more practice with the prompt, see using the Python interactive prompt.

Creating a Program in the IDLE Editor

Multi-line programs should normally be written in an editor window. The editor makes it easier to arrange statements, preserve indentation, correct mistakes, and save the complete program.

  1. In the Shell or an IDLE window, choose File > New File.
  2. Enter Python statements in the new editor window.
  3. Use the editor's syntax coloring and automatic indentation to help inspect the code.

For example, this short block uses indentation to place the print() statement inside the for loop:

for number in range(3):
    print(number)

The expected output is:

0
1
2

In Python, indentation is part of the syntax. The editor's auto-indent feature can help, but you should still make sure statements in the same block use consistent indentation.

Saving a Python Source File

  1. With the editor window active, choose File > Save.
  2. Choose a known folder where you can find the file later.
  3. Give the file a meaningful name ending in .py, such as hello.py.
  4. Confirm the save operation.

The .py extension identifies the file as Python source code. A meaningful filename, such as temperature_converter.py, is easier to recognize than a name such as untitled.py.

IDLE normally requires the editor contents to be saved before the file can be run as a module. Saving also protects your work and gives the program a stable location on disk.

Running a Script as a Module

After saving the editor file, choose Run > Run Module. You can also press F5. On some keyboards, function keys are assigned to hardware actions, so you may need to press Fn+F5.

IDLE runs the current saved file as a Python module. A module is a Python source file that can be executed or imported. Program output is sent to the Shell window, not displayed in the editor.

Before a module run, IDLE restarts the Shell execution environment. The Shell may show a message such as RESTART. RESTART is a status message indicating that IDLE reset the interpreter session; it is not the output produced by your program. Look below the restart indicator for printed output or error messages.

Try this complete workflow:

  1. Choose File > New File.
  2. Enter the following code:
print("Hello, Python!")
  1. Choose File > Save and use the filename hello.py.
  2. Choose Run > Run Module, or press F5.
  3. Return to the Shell and look below the restart message.
Hello, Python!

Task | Menu path | Keyboard shortcut | Result

Create a source file | File > New File | None required | A new editor window opens

Save a source file | File > Save | None required | The editor contents are stored as a .py file

Run the current module | Run > Run Module | F5, or Fn+F5 when required | The saved file runs and its output appears in the Shell

Shell Versus Editor

Characteristic | Shell | Editor

Best use case | Quick experiments and immediate questions | Reusable programs and multi-line code

How code is executed | A command runs when you press Enter at the prompt | The saved file runs with Run > Run Module

Whether work is saved as a script | Not automatically as one complete script | Yes, when saved with a .py filename

Where results appear | Directly below commands in the Shell | In the Shell after the module runs

A practical habit is to test a small expression in the Shell, then move any useful logic into an editor file when it needs to be reused.

Troubleshooting IDLE

IDLE is missing from the application menu

Python or the IDLE component may not be installed. Confirm that Python is installed, search for IDLE or IDLE with a Python version, and use the Python installer or operating-system package manager to add IDLE when necessary.

A multi-line program is difficult to edit in the Shell

The Shell is intended for interactive commands, not for maintaining complete programs. Choose File > New File, retype or move the code into the editor, save it as a .py file, and run it as a module.

Run Module does not work

First save the editor file. Then check the Shell for a traceback, syntax message, or indentation message. Correct the referenced line and verify that the filename ends in .py.

Expected output is missing

Switch to the Shell window after running the module. The editor does not display program output. Look below the RESTART indicator for printed output or errors. If the program should display a value, make sure it contains a statement such as print(value).

F5 does not run the script

Make sure the saved editor window is active. If the keyboard assigns another action to F5, try Fn+F5, or use Run > Run Module from the menu.

Basic IDLE Workflow

  1. Launch IDLE from your operating system's application menu or search.
  2. Use the Shell prompt, >>>, for a quick experiment such as 2 + 3.
  3. Choose File > New File for a multi-line program.
  4. Write the program in the editor and check its indentation.
  5. Choose File > Save and use a meaningful .py filename.
  6. Choose Run > Run Module or press F5.
  7. Read the program's output or errors in the Shell below any restart notification.

To continue, review writing your first Python program, running Python code, and Python syntax and logical errors. You can also learn how Python source files relate to modules.