code.interact()
code.interact() is a Python function in the Code Module category. Starts an interactive Python interpreter (like a REPL). The syntax is code.interact(banner=None, readfunc=None, local=None, exitmsg=None). Returns: None. A typical example: import code
code.interact(local=locals()) # Drop into interactive shell. A close sibling is code.compile_command(), which compiles a single Python command, detecting if it's complete or incomplete. A close sibling is code.InteractiveInterpreter(), which embeds a Python interpreter into an application. More about this category: Interactive interpreter — interact, compile_command, InteractiveInterpreter. Related Code Module entries: code.compile_command(), code.InteractiveInterpreter(). 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.interact() immediately in the Python playground, look up unfamiliar terms in the glossary, or return to the Python Reference homepage.