PYRS logo PYRS

REPL and Execution

Edit this page

Practical REPL workflow, execution modes, and debugging behavior in PYRS.

PYRS supports interactive REPL, stdin, inline command mode, module mode, script-file mode, and .pyc execution. This page focuses on high-signal REPL usage and when to switch to non-interactive runs.

Start in REPL First

Use REPL for rapid iteration and exploratory debugging:

Shell
$ pyrs

Prompt Model and Interactive Flow

The primary prompt (>>>) indicates a new statement. The continuation prompt (...) appears while completing blocks, multiline literals, or decorators/class definitions.

REPL Session
>>> from dataclasses import dataclass >>> @dataclass ... class User: ... name: str ... id: int ... >>> User("ada", 7) User(name='ada', id=7)

Execution State and Session Behavior

  • Imports and variable assignments persist for the lifetime of the REPL session.
  • Each entered statement executes in the current session state.
  • Restart REPL to clear state when debugging contamination between experiments.
State Persistence Example
>>> counter = 0 >>> counter += 1 >>> counter 1 >>> counter += 1 >>> counter 2

Error Feedback in Interactive Runs

Syntax and runtime failures are rendered with traceback context in CPython-style shapes. For repeatable bug reports, capture the exact failing snippet and include both PYRS and CPython output.

Runtime Error Shape
>>> items = {} >>> items["missing"] + 1 Traceback (most recent call last): File "<stdin>", line 1, in <module> KeyError: 'missing'

Exit, Interrupt, and Deterministic Runs

  • Ctrl+D exits the REPL on macOS/Linux terminals.
  • Ctrl+C interrupts the running statement where supported.
  • Use -c, -m, or script mode for reproducible automation and CI checks.
Shell
$ pyrs -c "import platform; print(platform.python_version())" $ pyrs -m http.server 8000 $ pyrs path/to/script.py

Troubleshooting Checklist

  • If interactive behavior differs from script mode, rerun with pyrs -c ... to isolate session state effects.
  • If imports fail unexpectedly, verify your import root and PYRS_CPYTHON_LIB setup.
  • When reporting REPL bugs, include prompt transcript and exact terminal platform details.