ptpython

ptpython is an enhanced interactive REPL for Python that supports multiline editing, syntax highlighting, and smart completion, with an optional IPython mode.

Installation and Setup

Install from the Python Package Index (PyPI) into a virtual environment:

Windows PowerShell
PS> py -m pip install ptpython
PS> py -m ptpython --version
PS> py -m ptpython
Shell
$ python -m pip install ptpython
$ python -m ptpython --version
$ python -m ptpython

Key Features

  • Multiline editing with automatic indentation and bracket matching for a smooth REPL workflow.
  • Rich UI with syntax highlighting, inline docstrings, and signature help during completion.
  • Powerful completion and history search with Emacs and Vi key bindings.
  • Customizable behavior and appearance through a Python-based config file.
  • Optional IPython front end through the ptipython command.

Usage

Start a session and evaluate expressions:

Shell
$ ptpython
>>> 2 + 2
4

Launch with IPython features:

Shell
$ ptipython

A minimal config file example that enables Vi key bindings and disables exit confirmation:

Python ~/.config/ptpython/config.py
def configure(repl):
    repl.vi_mode = True
    repl.confirm_exit = False

Embed an interactive shell inside an application for debugging:

Python script.py
from ptpython.repl import embed

def main():
    # Your program logic here...
    embed(globals(), locals())  # Drop into a REPL at runtime

if __name__ == "__main__":
    main()

Tutorial

Boost Your Coding Productivity With Ptpython

Learn how to enhance your Python development workflow with auto-completion, syntax highlighting, history navigation, and more. In this tutorial, you'll walk through the fundamentals of ptpython, covering installation, basic usage, and advanced features.

basics tools


By Leodanis Pozo Ramos • Updated Dec. 1, 2025