The new interactive REPL
suggest changePython 3.13 replaced the interactive interpreter (the REPL you get by running python with no arguments) with a new one based on code from the PyPy project. Before 3.13 the console used GNU readline on Linux and macOS and had almost no line editing on Windows. Every line of a function had to be recalled separately, pasted code with blank lines broke, and you had to type exit() with parentheses.
The new REPL gives you:
- multi-line editing: a whole function or
classcomes back from history as one block you can edit - automatic indentation after lines ending in
: - history browsing (F2), paste mode (F3) and interactive help (F1)
exit,quit,help,clear,copyright,creditsandlicensework without parentheses- colored prompts and colored tracebacks
- the same behaviour on Windows, Linux and macOS
Python 3.14 added syntax highlighting as you type and Tab completion of module names in import statements.
The second half of this article covers a related improvement: the friendlier error messages added in Python 3.10 through 3.14. You see most of them for the first time in the REPL.
For starting the console and running code at startup, see Opening the Python console and The PYTHONSTARTUP variable.
Sessions were captured with Python 3.13.15 on Windows and Python 3.14.4 on Ubuntu (WSL). The REPL was driven through a pseudo-terminal and the screen rendered back to text. Colors don't show up in this text.
Multi-line editing and auto-indent
Type a function definition. After a line ending in : the REPL indents the next line for you. Below, return n * 2 was typed with no leading spaces. An empty line ends the block:
Python 3.13.15 (tags/v3.13.15:4061bc4, Aug 5 2026, 13:05:39) [MSC v.1944 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> def f(n):
... return n * 2
...
>>> f(21)
42
The big change is how history works. In the old REPL, pressing the up arrow recalled return n * 2 on its own, so fixing a typo in a 10-line function meant retyping it line by line. Now the up arrow recalls the whole block as one entry:
>>> def area(w, h):
... return w * h
...
>>> area(3, 4)
12
>>> def area(w, h): <- pressed Up twice
... return w * h
Once recalled, the up and down arrows move between the lines of the block, and Home/End move within a line. Here I moved to the first line, changed the signature, moved down, appended * scale, and pressed Enter twice (the second Enter, on an empty line, runs the block):
>>> def area(w, h, scale=1):
... return w * h * scale
...
>>> area(3, 4, scale=10)
120
Other editing keys are the usual Emacs-style ones: Ctrl-A / Ctrl-E (start and end of line), Ctrl-K (delete to the end of the line), Ctrl-U (delete to the start of the line), and Ctrl-R for reverse search through history:
>>> total = sum(range(10))
>>> names = ['ada', 'bob']
>>> len(names)
2
(r-search `sum') total = sum(range(10))
Pressing Enter accepts the match into the prompt, where you can edit it before running it.
Commands without parentheses
In the old REPL exit was an ordinary object whose repr told you how to exit. The new REPL treats exit, quit, help, clear, copyright, credits and license as commands when you type them alone on a line:
>>> exit
That closes the REPL. The same line in the old REPL only prints a hint:
>>> exit
Use exit() or Ctrl-D (i.e. EOF) to exit
>>>
This only applies to a bare name typed at the prompt. Inside an expression exit is still the same object. If you define a variable with one of these names, your variable wins:
>>> print(exit)
Use exit() or Ctrl-D (i.e. EOF) to exit
>>> exit = 42
>>> exit
42
>>> del exit
clear clears the screen (the same as Ctrl-L). help starts the interactive help utility, which now also lists the new keyboard shortcuts:
>>> help
Welcome to Python 3.14's help utility! If this is your first time using
Python, you should definitely check out the tutorial at
https://docs.python.org/3.14/tutorial/.
Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules. To get a list of available
modules, keywords, symbols, or topics, enter "modules", "keywords",
"symbols", or "topics".
You can use the following keyboard shortcuts at the main interpreter prompt.
F1: enter interactive help, F2: enter history browsing mode, F3: enter paste
mode (press again to exit).
Each module also comes with a one-line summary of what it does; to list
the modules whose name or summary contain a given string such as "spam",
enter "modules spam".
To quit this help utility and return to the interpreter,
enter "q", "quit" or "exit".
help> q
At the help> prompt you can type a name such as str.split to read its documentation. help(obj) with parentheses still works as before. See Getting help about an object.
History browsing with F2
F2 opens your history in a pager (the one in the PAGER environment variable, or less / more). It shows only the code you typed: no >>> and ... prompts and no output. That's the easiest way to copy a few lines you tried in the REPL into a script:
def area(w, h):
return w * h
area(3, 4)
def area(w, h, scale=1):
return w * h * scale
area(3, 4, scale=10)
hist.txt line 1/8 (END) (press h for help or q to quit)
Press q to go back to the prompt.
History is saved to ~/.python_history (%USERPROFILE%\.python_history on Windows) and loaded when you start the next REPL. Python 3.13 added the PYTHON_HISTORY environment variable to pick another file. For example, you can keep a separate history per project:
$ export PYTHON_HISTORY=$PWD/.python_history
$ python3.14
The REPL whose history is shown above was started with PYTHON_HISTORY pointing at hist.txt. That's why the pager shows that file name.
Pasting code with F3 and bracketed paste
Pasting code into the old REPL often failed. A blank line inside a class body ended the block, and the following indented line then raised IndentationError. This is what still happens in the basic REPL:
>>> class Point:
... def __init__(self, x, y):
... self.x, self.y = x, y
...
>>> def __repr__(self):
File "<stdin>", line 1
def __repr__(self):
IndentationError: unexpected indent
>>>
The new REPL has a paste mode. Press F3, paste, then press F3 again. The prompt changes to (paste) and nothing runs until you leave paste mode. Auto-indentation is turned off, so pasted lines aren't indented twice:
(paste) class Point:
(paste) def __init__(self, x, y):
(paste) self.x, self.y = x, y
(paste)
(paste) def __repr__(self):
(paste) return f'Point({self.x}, {self.y})'
(paste)
(paste) p = Point(1, 2)
(paste) print(p)
After the second F3 the whole paste is one block. Press Enter to run it:
Point(1, 2)
>>>
Most terminals send pasted text wrapped in "bracketed paste" escape codes, and the new REPL understands them. That means an ordinary paste usually works without F3. The whole snippet, blank lines included, lands in the prompt as one block, and Enter on an empty last line runs it:
>>> class Point:
... def __init__(self, x, y):
... self.x, self.y = x, y
...
... def __repr__(self):
... return f'Point({self.x}, {self.y})'
...
... p = Point(1, 2)
... print(p)
...
Point(1, 2)
>>>
F3 is still useful in terminals that don't support bracketed paste.
Tab completion
Tab completes names, attributes and keywords, as before. A single match is filled in, and pressing Tab again on several matches lists them:
>>> import json
>>> json.dump
json.dump( json.dumps(
Python 3.14 also completes module names in import and from ... import statements. Python 3.13 doesn't: Tab after import col does nothing there. In 3.14:
>>> import col
collections colorsys
>>> from concurrent import
futures interpreters
When only one module matches, Tab completes it, including submodules after a dot. import collections. followed by Tab becomes import collections.abc.
Import completion only suggests modules and submodules. from collections import Ord and Tab doesn't complete OrderedDict, because OrderedDict is a class, not a submodule.
Colors and syntax highlighting
Both REPLs color the prompt (bold magenta) and tracebacks: file names and line numbers in magenta, the failing expression in red, the exception type in bold magenta. The traceback below is from 3.14. On the screen f(1) and x / 0 are red, and the ^ markers point at the exact part of the expression that failed:
>>> def f(x): # comment
... return x / 0
...
>>> f(1)
Traceback (most recent call last):
File "<python-input-1>", line 1, in <module>
f(1)
~^^^
File "<python-input-0>", line 2, in f
return x / 0
~~^~~
ZeroDivisionError: division by zero
Code typed in the REPL comes from a pseudo-file named <python-input-N>, one per entry. The old REPL used <stdin> for everything.
Python 3.14 also highlights code as you type: keywords and True/False/None in bold blue, built-ins in cyan, strings in green, numbers in yellow, comments in red, and the name in a def or class statement in bold. In the raw terminal output, def f(x): # comment looks like this (ESC is the escape character):
ESC[1;34mdefESC[0m ESC[1mfESC[0m(x): ESC[31m# commentESC[0m
Python 3.13 sends the same line with no color codes.
You can change the colors with the _colorize module. It's private and documented as experimental, so it may change in a future release. Put this in a PYTHONSTARTUP file:
from _colorize import ANSIColors, default_theme, set_theme
set_theme(default_theme.copy_with(
syntax=default_theme.syntax.copy_with(
keyword=ANSIColors.BOLD_GREEN,
string=ANSIColors.YELLOW,
),
))
With it, if True: s = 'hi' shows if in bold green and 'hi' in yellow (ESC[1;32mif, ESC[33m'hi').
Colors are on when output goes to a terminal. Turn them off with either environment variable:
PYTHON_COLORS=0(Python-specific;PYTHON_COLORS=1forces color on)NO_COLOR=1(the cross-tool no-color.org convention)
FORCE_COLOR=1 turns colors on even when output isn't a terminal. With PYTHON_COLORS=0 or NO_COLOR=1, the session above contains no color escape codes at all.
Falling back to the basic REPL
Set PYTHON_BASIC_REPL to any non-empty value to get the old REPL:
$ PYTHON_BASIC_REPL=1 python3.14
Python 3.14.4 (main, Aug 20 2026, 10:41:58) [GCC 15.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit
Use exit() or Ctrl-D (i.e. EOF) to exit
>>>
On Windows: set PYTHON_BASIC_REPL=1 in cmd or $env:PYTHON_BASIC_REPL = "1" in PowerShell.
The basic REPL uses readline where it is available. It has no auto-indent, block history, F-keys or syntax highlighting, and you need exit(). Tracebacks are still colored, because that's done by the traceback module, not the REPL.
Python also uses the basic REPL on its own when the new one can't work. If the terminal lacks the required capabilities, it prints a warning:
$ TERM=dumb python3.14
Python 3.14.4 (main, Aug 20 2026, 10:41:58) [GCC 15.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
warning: can't use pyrepl: (5, "terminal doesn't have the required clear capability"); TERM=dumb
>>> exit
Use exit() or Ctrl-D (i.e. EOF) to exit
>>>
It also does this, silently, when standard input isn't a terminal, for example when code is piped into python -i. Then exit without parentheses doesn't exit:
$ printf 'import sys\nprint(sys.version_info[:2])\nexit\nprint("not reached?")\n' | python -i -q
>>> >>> (3, 13)
>>> Use exit() or Ctrl-Z plus Return to exit
>>> not reached?
>>>
Use the basic REPL if a screen reader, an unusual terminal or an IDE console has trouble with the new one, or if you rely on settings in ~/.inputrc. The new REPL doesn't read readline configuration.
Friendlier error messages (3.10 to 3.14)
Since Python 3.10, each release has improved error messages. Most of them help most when you are typing code into the REPL. The examples below were run as scripts (paths shortened). The REPL prints the same messages.
Syntax errors (3.10)
Python 3.10 got a new parser, which made much more precise syntax errors possible. An unclosed bracket is reported where it was opened, not at the end of the file:
data = {"a": 1, "b": 2
print(data)
File "e01.py", line 1
data = {"a": 1, "b": 2
^
SyntaxError: '{' was never closed
Missing commas, = instead of ==, and missing colons:
File "e02.py", line 1
items = [1, 2 3]
^^^
SyntaxError: invalid syntax. Perhaps you forgot a comma?
File "e03.py", line 2
if x = 1:
^^^^^
SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='?
File "e04.py", line 1
def f()
^
SyntaxError: expected ':'
Indentation errors name the statement that needs a body:
File "e05.py", line 2
pass
^^^^
IndentationError: expected an indented block after 'if' statement on line 1
"Did you mean" for names and attributes (3.10)
NameError and AttributeError suggest similar names that exist:
Traceback (most recent call last):
File "e06.py", line 2, in <module>
print(number_of_itmes)
^^^^^^^^^^^^^^^
NameError: name 'number_of_itmes' is not defined. Did you mean: 'number_of_items'?
Traceback (most recent call last):
File "e07.py", line 2, in <module>
collections.namedtupel
AttributeError: module 'collections' has no attribute 'namedtupel'. Did you mean: 'namedtuple'?
Precise error locations (3.11)
PEP 657 added column information to tracebacks. ~ underlines the expression and ^ marks the operation that failed. With several subscripts on one line you can see which lookup raised KeyError:
import math
r = {"radius": 2.0}
area = math.pi * r["radius"] ** 2 / (r["width"] - 1)
Traceback (most recent call last):
File "e15.py", line 3, in <module>
area = math.pi * r["radius"] ** 2 / (r["width"] - 1)
~^^^^^^^^^
KeyError: 'width'
Missing imports, self. and import typos (3.12)
Using a standard library module you forgot to import:
Traceback (most recent call last):
File "e08.py", line 1, in <module>
print(sys.argv)
^^^
NameError: name 'sys' is not defined. Did you forget to import 'sys'?
Forgetting self. inside a method:
class Counter:
def __init__(self):
self.count = 0
def current(self):
return count
print(Counter().current())
Traceback (most recent call last):
File "e11.py", line 8, in <module>
print(Counter().current())
~~~~~~~~~~~~~~~~~^^
File "e11.py", line 6, in current
return count
^^^^^
NameError: name 'count' is not defined. Did you mean: 'self.count'?
A wrong name in from ... import, and import / from in the wrong order:
Traceback (most recent call last):
File "e09.py", line 1, in <module>
from collections import chainmap
ImportError: cannot import name 'chainmap' from 'collections' (...\Lib\collections\__init__.py). Did you mean: 'ChainMap'?
File "e10.py", line 1
import a.b.c from d
^^^^^^^^^^^^^^^^^^^
SyntaxError: Did you mean to use 'from ... import ...' instead?
Keyword arguments and shadowed modules (3.13)
A misspelled keyword argument gets a suggestion:
Traceback (most recent call last):
File "e12.py", line 1, in <module>
sorted([3, 1, 2], reversed=True)
~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: sort() got an unexpected keyword argument 'reversed'. Did you mean 'reverse'?
Naming your script after a standard library module is a classic beginner mistake. A file called random.py that does import random imports itself. Python 3.13 detects this:
# random.py
import random
print(random.randint(1, 6))
Traceback (most recent call last):
File "random.py", line 1, in <module>
import random
File "random.py", line 2, in <module>
print(random.randint(1, 6))
^^^^^^^^^^^^^^
AttributeError: module 'random' has no attribute 'randint' (consider renaming 'C:\...\random.py' since it has the same name as the standard library module named 'random' and prevents importing that standard library module)
Keyword typos and more (3.14)
Python 3.14 suggests the right keyword when you misspell one. Python 3.13 only said invalid syntax and pointed at the wrong place:
$ python whille.py # 3.13
File "whille.py", line 1
whille True:
^^^^
SyntaxError: invalid syntax
$ python3.14 whille.py
File "whille.py", line 1
whille True:
^^^^^^
SyntaxError: invalid syntax. Did you mean 'while'?
Other 3.14 messages that used to be a plain invalid syntax:
x = 1
if x > 0:
pass
else:
pass
elif x < 0:
pass
File "e14.py", line 6
elif x < 0:
^^^^
SyntaxError: 'elif' block follows an 'else' block
File "e17.py", line 1
x = 1 if True else pass
^^^^
SyntaxError: expected expression after 'else', but statement is given
Some runtime errors also explain more. In 3.13, {[1, 2]} raised TypeError: unhashable type: 'list'. In 3.14 it says what the value was used for:
Traceback (most recent call last):
File "e16.py", line 1, in <module>
s = {[1, 2]}
^^^^^^^^
TypeError: cannot use 'list' as a set element (unhashable type: 'list')
Summary
| Feature | Version |
|---|---|
New REPL: block editing, auto-indent, F1/F2/F3, exit without (), colored prompt |
3.13 |
PYTHON_HISTORY, PYTHON_BASIC_REPL, PYTHON_COLORS |
3.13 |
| Colored tracebacks | 3.13 |
Syntax highlighting while typing, Tab completion of import |
3.14 |
| Precise syntax errors, "Did you mean" for names and attributes | 3.10 |
Fine-grained ~^^^ error locations |
3.11 |
"Did you forget to import", self. suggestions, from ... import hints |
3.12 |
| Keyword argument suggestions, stdlib shadowing warning | 3.13 |
Keyword typo suggestions, elif after else, set/dict element messages |
3.14 |