Registry / testing / ptpython

ptpython

JSON →
library3.0.32pypypi✓ verified 35d ago

ptpython is an advanced, cross-platform Python REPL (Read-Eval-Print Loop) built on top of the prompt_toolkit library. It provides features like syntax highlighting, autocompletion, multiline editing, mouse support, and customizable key bindings (Emacs and Vi modes). Currently at version 3.0.32, it sees fairly frequent updates, often with several patch releases per month.

testing
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Used to embed the ptpython REPL directly into a Python application or script. It's common to pass `globals()` and `locals()` to make current scope variables available.

from ptpython.repl import embed

Used to explicitly load a configuration file when embedding the REPL, as configuration files are otherwise ignored in embedded mode.

from ptpython.repl import run_config

To start a `ptpython` shell, simply run `ptpython` in your terminal. To embed it in a Python script for debugging or interactive sessions, use `ptpython.repl.embed()`. You should pass `globals()` and `locals()` to `embed()` to make the current scope available inside the REPL.

import os from ptpython.repl import embed def main(): print("Entering embedded ptpython REPL...") my_variable = "Hello from host script" # Pass globals() and locals() to make variables accessible in the REPL embed(globals(), locals()) print("Exited embedded ptpython REPL.") if __name__ == "__main__": # Or simply run from command line: # $ ptpython main()
ptpython --version
Debug
Known footguns
breakingPython 3.7 support was dropped in version 3.0.30. Users on Python 3.7 or older must use an earlier ptpython version (e.g., ptpython 2.0.5 for Python < 3.6, or a 2.x version for Python 3.7).
gotchaWhen embedding the REPL using `ptpython.repl.embed()`, configuration files (e.g., `~/.config/ptpython/config.py`) are ignored by default. This can lead to unexpected behavior if you rely on custom settings.
breakingSince version 3.0.24, the `--asyncio` flag is explicitly required to activate the asyncio REPL when running `ptpython` from the command line. Previously, asyncio mode might have been implicitly active under certain conditions.
gotchaVersion 3.0.28 introduced a custom `exit` function that can be called without parentheses (i.e., just `exit`) to return from the REPL when embedded. While convenient, users accustomed to always calling `exit()` might find this behavior unexpected.
gotchaIn version 3.0.32, the default code theme ('default-ansi') switched to using ANSI colors instead of RGB. This can alter the appearance of syntax highlighting depending on your terminal emulator's color configuration, potentially affecting contrast.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
0 hits · last 30 days

No traffic data recorded yet.

Resources