+
Python 3.14 Preview: REPL Autocompletion and Highlighting

Python 3.14 Preview: REPL Autocompletion and Highlighting

by Leodanis Pozo Ramos Publication date Sep 17, 2025 Reading time estimate 12m basics python

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 the PYTHONSTARTUP script.
  • You can disable the syntax highlighting by setting NO_COLOR=1 or PYTHON_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.

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 Highlighting

Take 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 or NO_COLOR environment variables.
  • Quick REPL commands: Use exit, quit, help, and clear 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:

Syntax Highlighting in Python 3.14's REPL

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.

Go ahead and run the command below:

Windows PowerShell
PS> $env:PYTHONSTARTUP="$HOME\.pythonstartup"
Shell
$ export PYTHONSTARTUP=~/.pythonstartup

Then, create a .pythonstartup file in your home folder and add the following code to it:

Python .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() from dataclasses and the _colorize API, including ANSIColors, default_theme, and set_theme()
  • Uses a tryexcept 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:

Default vs Custom Colors in Python 3.14's REPL

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 over FORCE_COLOR.
  • PYTHON_COLORS: Set it to 0 to disable colors, including syntax highlighting, or to 1 to enable them. This variable overrides NO_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:

Windows PowerShell
PS> $env:PYTHON_BASIC_REPL = "1"
PS> python
Shell
$ PYTHON_BASIC_REPL=1 python

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.

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 Highlighting

Take this quiz to explore Python 3.14's REPL upgrades! Test your knowledge of new autocompletion tools and built-in syntax highlighting.

🐍 Python Tricks 💌

Get a short & sweet Python Trick delivered to your inbox every couple of days. No spam ever. Unsubscribe any time. Curated by the Real Python team.

Python Tricks Dictionary Merge

About Leodanis Pozo Ramos

Leodanis is a self-taught Python developer, educator, and technical writer with over 10 years of experience.

» More about Leodanis

Each tutorial at Real Python is created by a team of developers so that it meets our high quality standards. The team members who worked on this tutorial are:

Master Real-World Python Skills With Unlimited Access to Real Python

Locked learning resources

Join us and get access to thousands of tutorials, hands-on video courses, and a community of expert Pythonistas:

Level Up Your Python Skills »

Master Real-World Python Skills
With Unlimited Access to Real Python

Locked learning resources

Join us and get access to thousands of tutorials, hands-on video courses, and a community of expert Pythonistas:

Level Up Your Python Skills »

What Do You Think?

Rate this article:

What’s your #1 takeaway or favorite thing you learned? How are you going to put your newfound skills to use? Leave a comment below and let us know.

Commenting Tips: The most useful comments are those written with the goal of learning from or helping out other students. Get tips for asking good questions and get answers to common questions in our support portal.


Looking for a real-time conversation? Visit the Real Python Community Chat or join the next “Office Hours” Live Q&A Session. Happy Pythoning!
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载