On this page
  1. code.InteractiveInterpreter
  2. Import
  3. Signature & Overview
  4. Methods & Attributes
  5. Usage
  6. Gotchas
  7. REPL Inspect

code.InteractiveInterpreter

Prev: code.InteractiveConsole | Up: code
Rel: code.compile_command, code.interact, code.InteractiveConsole
Ref: docs.python.org — code.InteractiveInterpreter
Tags: #public #python3 #stdlib #code


Import

import code
from code import InteractiveInterpreter

Signature & Overview

code.InteractiveInterpreter(locals=None)

Base class for InteractiveConsole.

Methods & Attributes

Usage

import code

ns: dict[str, object] = {}
interp = code.InteractiveInterpreter(locals=ns)
assert interp.runsource("total = 21 + 21") is False
assert ns["total"] == 42

Gotchas

REPL Inspect

from code import InteractiveInterpreter
help(InteractiveInterpreter)

Linked from

Related notes