Python 3.13 PyREPL: New Features and Improvements
Python 3.13 revamps the interactive terminal experience by integrating a new default interactive shell based on code from PyPy, known as PyREPL. This update replaces the legacy Readline-based console with a modern, feature-rich interface that supports native multiline code editing, colorized syntax highlighting, improved paste handling, and consistent cross-platform behavior across Windows, macOS, and Linux.
Native Multiline Editing
The most noticeable upgrade is full multiline editing. In previous
versions, writing a function, class, or loop in the REPL locked
previously entered lines once the user pressed Enter; mistakes required
rewriting the block from scratch or hitting Ctrl+C. With
PyREPL, developers can use the up and down arrow keys to navigate freely
between multiple lines within the current block to modify statements,
fix syntax errors, and adjust indentation before execution.
Built-in Syntax Highlighting
The new interactive shell introduces real-time syntax highlighting
out of the box, without requiring third-party tools like IPython or
ptpython. Keywords, built-in functions, strings, and
numeric literals are color-coded dynamically as they are typed. Python
3.13 also colorizes error tracebacks directly in the REPL, making
exception tracking and debugging faster and visually distinct.
Robust Paste Support
Pasting multiline snippets into the legacy terminal frequently resulted in indentation errors, premature code execution, or misordered commands. PyREPL includes bracketed paste support and a dedicated paste mode. This ensures large blocks of code, complete functions, and copied documentation examples retain their formatting and indentation without executing line-by-line prematurely.
Interactive Shortcuts and Commands
PyREPL introduces intuitive keyboard shortcuts to streamline workflows within the session:
- F1: Opens integrated interactive help and documentation for the object or function currently under the cursor.
- F2: Toggles history browsing, allowing quick access to previous commands without repeatedly pressing the up arrow.
- F3: Toggles paste mode for inserting formatted or non-standard text blocks cleanly.
Cross-Platform Consistency
Historically, Windows users had an inferior REPL experience compared to Unix users due to differences between the standard Windows console and Unix GNU Readline. Because PyREPL is implemented in pure Python, it runs natively across Windows, Linux, and macOS. This eliminates reliance on platform-dependent C libraries and delivers an identical, modern interactive interface regardless of operating system.
Opt-Out and Legacy Support
For environments where the new terminal behavior may conflict—such as
legacy terminal emulators, accessibility screen readers, or automated
scripts piped into python—Python 3.13 allows users to
revert to the classic Readline implementation by setting the environment
variable PYTHON_BASIC_REPL=1.