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:
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
ptipythoncommand.
Usage
Start a session and evaluate expressions:
$ ptpython
>>> 2 + 2
4
Launch with IPython features:
$ ptipython
A minimal config file example that enables Vi key bindings and disables exit confirmation:
~/.config/ptpython/config.py
def configure(repl):
repl.vi_mode = True
repl.confirm_exit = False
Embed an interactive shell inside an application for debugging:
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()
Related Resources
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.
By Leodanis Pozo Ramos • Updated Dec. 1, 2025