Python 3.14 introduces improvements to its interactive shell (REPL), bringing a more modern, colorful, and user-friendly environment. The new features make the Python 3.14 REPL a powerful tool for experimentation. Whether you’re testing a quick idea, exploring a new library, or debugging a tricky snippet, the REPL gives you instant feedback—no files, no setup, just type and run.
The default CPython REPL intentionally kept things minimal. It was fast, reliable, and available everywhere, but it lacked the richer, more ergonomic features found in tools like IPython or ptpython. That began to change in Python 3.13, when CPython adopted a modern PyREPL-based shell by default, adding multiline editing, better history navigation, and smarter Tab completion.
By the end of this tutorial, you’ll understand that:
- In Python 3.14’s REPL, autocompletion is on by default. You just need to press Tab in the context of an
import
statement to see possible completion suggestions. - The REPL highlights Python syntax in real time if your terminal supports ANSI colors.
- Python 3.14 allows you to customize the color theme with the
_colorize.set_theme()
experimental API and thePYTHONSTARTUP
script. - You can disable the syntax highlighting by setting
NO_COLOR=1
orPYTHON_COLORS=0
in your environment.
Autocompleting module names during import
statements makes interactive coding smoother and faster, especially for learning or exploratory tasks. In addition, the colored syntax in the REPL improves readability, making it easier to spot typos and syntax issues.
Get Your Code: Click here to download the free sample code that you’ll use to learn about REPL autocompletion and highlighting in Python 3.14.
Take the Quiz: Test your knowledge with our interactive “Python 3.14 Preview: REPL Autocompletion and Highlighting” quiz. You’ll receive a score upon completion to help you track your learning progress:
Interactive Quiz
Python 3.14 Preview: REPL Autocompletion and HighlightingTake this quiz to explore Python 3.14's REPL upgrades! Test your knowledge of new autocompletion tools and built-in syntax highlighting.
The Interactive REPL Before Python 3.14
When you first install Python, one of the most immediate ways to try it out is through the interactive REPL (Read–Eval–Print Loop) in your command line or terminal. The REPL is a shell that lets you type Python code, run it instantly, and see the result. It’s a quick-start environment perfect for experimentation, learning, and debugging without the overhead of creating and running separate scripts.
For years, the default CPython REPL kept things lightweight and fairly minimal, with very few features. In contrast, tools like IPython, bpython, and ptpython have offered richer interactive experiences.
This landscape has been changing lately. Starting in Python 3.13, the default REPL is based on PyPy’s pyrepl
, which is written in Python and designed for extensibility and safety. It’s also a more capable interactive shell with a modern set of features:
- Color by default: Take advantage of colorized prompts and tracebacks. You can also control this behavior with the
PYTHON_COLORS
orNO_COLOR
environment variables. - Quick REPL commands: Use
exit
,quit
,help
, andclear
as commands rather than function calls with parentheses. - Built‑in help browser: Press F1 to open a help viewer in your pager so you can browse docs for Python, modules, and objects.
- Persistent history browser: Press F2 to open your command history in a pager and keep it across sessions so you can copy and reuse code.
- Multiline editing: Edit and rerun entire code blocks—functions, classes, loops—as a single unit. The block structure is preserved in your history.
- Robust pasting and paste mode: Paste whole scripts or larger code blocks reliably by default. Optionally, you can access paste mode with F3, although direct pasting usually works without issue.
- Smarter Tab completion: Completions update as you type and hide irrelevant suggestions to reduce noise.
In Python 3.14, the REPL has taken another leap forward by including the following improvements:
- Extended autocompletion that now covers module and submodule names in
import
statements - Live syntax highlighting that makes your interactive code as readable as in your favorite code editor or IDE
You don’t need to perform any extra installation or configuration to start using these new features as long as your terminal supports ANSI color output.
In the sections ahead, you’ll explore what these improvements look like in practice, learn how to use them in your workflow, and pick up some troubleshooting tips for when things don’t behave quite as expected.
Autocompletion Improvements
Python 3.14 extends the autocompletion logic to recognize import
contexts and suggest module or package names accordingly. Now, when you type an import
or from ... import
statement and press Tab, the REPL will search the import path for available module names matching the partial text.
For example, if you type import
and then press Tab twice, you’ll get the complete list of currently available modules and packages. If you start typing a module’s name like pat
and press Tab, the REPL will automatically complete the pathlib
name because it matches uniquely with the partial text.
Similarly, if you type something like import lo
and press Tab after lo
, then you’ll get a message saying that the match isn’t unique. Once there, you can press Tab again to get the complete list of matching names or continue typing to make the search pattern more specific:
In a from ... import ...
construct, you can list matching modules or packages after from
, and submodules or subpackages after import
. This feature allows you to quickly discover and complete module names interactively:
In practice, you can also use the from ... import ...
construct to import specific objects, such as functions and classes, from a given module. However, in this case, the autocomplete doesn’t work for the object’s name:
When you type from sys import ...
and then start to write the name version
, pressing Tab has no effect. This limitation exists because the REPL would need to import the module and introspect its objects to be able to provide autocompletion suggestions.
Syntax Highlighting
The REPL now highlights Python syntax in real time as you type code. This feature enhances readability and makes it easier to identify different elements of Python code, including keywords, strings, comments, and other syntax elements. All these elements are now displayed in different colors by default:
In this example, you can see how the REPL now highlights the Python syntax as you type. This feature helps you quickly spot syntax errors as you write the code.
Here’s an example of how other syntax constructs look with the new highlighting:
This syntax highlighting feature is enabled by default whenever you start a REPL session in a color-capable terminal emulator such as Terminal.app, iTerm2, or Windows Terminal, when running shells like Bash, Zsh, and PowerShell.
This highlighting applies the same color scheme used for colored tracebacks in Python 3.13. The default color theme provides high-contrast highlighting using standard 16-color ANSI codes, ensuring broad compatibility with most terminals.
Internally, the REPL tokenizes the code as you type and applies color codes to the text. Using ANSI escape codes guarantees that no special GUI is required—it works in any text terminal that supports these codes.
With this implementation, keywords will appear in one color, string literals in another, comments in another, and so on.
Customizing the Color Theme
In Python 3.14, the default colors and font formatting settings for the syntax highlighting feature are as follows:
Syntax Element | Default Color |
---|---|
Prompt | ANSIColors.BOLD_MAGENTA |
Keyword | ANSIColors.BOLD_BLUE |
Soft keyword | ANSIColors.BOLD_BLUE |
Built-in name | ANSIColors.CYAN |
Comment | ANSIColors.RED |
String | ANSIColors.GREEN |
Number | ANSIColors.YELLOW |
Operator | ANSIColors.RESET |
You can use an experimental API by calling _colorize.set_theme()
to customize the color theme programmatically. You can invoke this API during a session or use the PYTHONSTARTUP
environment variable and a custom startup file to tweak how different syntax elements are colored.
Note: The _colorize.set_theme()
API is currently experimental and may change in future Python versions. So, you should keep in mind that the interface and its behavior aren’t yet considered stable. This status is explicitly mentioned on the What’s new in Python 3.14? page.
Go ahead and run the command below:
Then, create a .pythonstartup
file in your home folder and add the following code to it:
.pythonstartup
try:
from dataclasses import replace
from _colorize import ANSIColors, default_theme, set_theme
except ImportError:
pass
else:
theme = default_theme.copy_with(
syntax=replace(
default_theme.syntax,
keyword=ANSIColors.BOLD_YELLOW,
string=ANSIColors.INTENSE_BLUE,
number=ANSIColors.RED,
comment=ANSIColors.GREY,
),
)
set_theme(theme)
Here’s a quick summary of what the startup script does:
- Imports
replace()
fromdataclasses
and the_colorize
API, includingANSIColors
,default_theme
, andset_theme()
- Uses a
try
…except
block to skip older Python versions or environments without_colorize
, avoiding errors - Builds a new theme by copying
default_theme
and overriding selected syntax colors:keyword
,string
,number
,comment
- Calls
set_theme()
so the custom colors are applied before the first prompt
With this file in place, go ahead and open a new terminal window. Below is a visual comparison between the default theme and your custom one:
On the left, you have the default color theme, and on the right, you have your custom color theme. Which one do you like better? You can play around with other color combinations and create your own theme with your favorite colors and font formatting. Go ahead and give it a try!
Finally, if you want to return to the default color theme, run unset PYTHONSTARTUP
and restart the REPL.
Toggling Colors
You can disable syntax highlighting by disabling the color capabilities. To do this, you can set these environment variables:
NO_COLOR
: Set it to any non-empty value to disable all colorized output. This variable takes precedence overFORCE_COLOR
.PYTHON_COLORS
: Set it to0
to disable colors, including syntax highlighting, or to1
to enable them. This variable overridesNO_COLOR
for the Python interpreter.
If your environment or terminal doesn’t support colors, then the REPL will fall back to plain text.
Returning to the Classic REPL
If you ever want to return to the basic REPL mode, then you can take advantage of PYTHON_BASIC_REPL
. Set it to any value to force the classic REPL with no PyREPL features at all. Note that this action disables syntax highlighting, the history browser, paste mode, and other modern features.
Here’s how you can set this environment variable:
Once you run these commands, you’ll be presented with the classic Python REPL, which is lightweight and has fewer features.
Conclusion
You’ve explored the new REPL features introduced in Python 3.14, including extended autocompletion for import
statements and real-time syntax highlighting. You’ve seen how the REPL now suggests module and package names as you type, and how it visually distinguishes different Python syntax elements with colors.
You also customized the color theme to fit your preferences and learned how to disable the highlighting features if needed.
Staying up to date with these REPL improvements is especially valuable for developers who rely on the shell for prototyping, debugging, or exploring libraries.
In this tutorial, you’ve learned how to:
- Use autocompletion for module and package names in
import
statements when using the Python 3.14 REPL - Take advantage of real-time syntax highlighting for improved readability and error detection
- Customize the REPL color theme using the experimental
_colorize.set_theme()
API and a startup script - Disable color output or switch back to the classic REPL using environment variables
With these skills, you can get more out of Python’s latest REPL enhancements, boosting both your productivity and your interactive coding experience.
Get Your Code: Click here to download the free sample code that you’ll use to learn about REPL autocompletion and highlighting in Python 3.14.
Frequently Asked Questions
Now that you have some experience with the new REPL features in Python 3.14, you can use the questions and answers below to check your understanding and recap what you’ve learned.
These FAQs are related to the most important concepts you’ve covered in this tutorial. Click the Show/Hide toggle beside each question to reveal the answer.
You press Tab while typing an import
or from ... import ...
statement, and the REPL will show matching module and submodule names from your import path.
It tokenizes your code as you type and uses ANSI escape codes to color different syntax elements, such as keywords, strings, and comments.
Yes, you can. Call the experimental _colorize.set_theme()
API directly in a REPL session or set up a startup file using the PYTHONSTARTUP
environment variable.
You can set NO_COLOR
to any value, PYTHON_COLORS
to 0
, or PYTHON_BASIC_REPL
to force the classic REPL without syntax highlighting.
Take the Quiz: Test your knowledge with our interactive “Python 3.14 Preview: REPL Autocompletion and Highlighting” quiz. You’ll receive a score upon completion to help you track your learning progress:
Interactive Quiz
Python 3.14 Preview: REPL Autocompletion and HighlightingTake this quiz to explore Python 3.14's REPL upgrades! Test your knowledge of new autocompletion tools and built-in syntax highlighting.