code.InteractiveInterpreter()
code.InteractiveInterpreter() is a Python function in the Code Module category. Embeds a Python interpreter into an application. The syntax is code.InteractiveInterpreter(locals=None). Returns: InteractiveInterpreter object. A typical example: interp = code.InteractiveInterpreter()
interp.runsource("print(\"Hello\")"). A close sibling is code.interact(), which starts an interactive Python interpreter (like a REPL). A close sibling is code.compile_command(), which compiles a single Python command, detecting if it's complete or incomplete. More about this category: Interactive interpreter — interact, compile_command, InteractiveInterpreter. Related Code Module entries: code.interact(), code.compile_command(). This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details. You can try code.InteractiveInterpreter() immediately in the Python playground, look up unfamiliar terms in the glossary, or return to the Python Reference homepage.