pydoc > code

πŸ“˜ NAME

code - Utilities needed to emulate Python's interactive interpreter.

πŸš€ Quick Reference

Use CaseCommandDescription
πŸ–₯ Start interactive consoleinteract(banner=None, readfunc=None, local=None, exitmsg=None)Closely emulate the interactive Python interpreter with optional banner and exit message
πŸ” Compile a command stringcompile_command(source, filename='<input>', symbol='single')Compile source and determine if complete, incomplete, or error; returns code object, None, or raises SyntaxError
πŸ›  Create InteractiveConsoleInteractiveConsole(locals=None, filename='<console>')Class that builds on InteractiveInterpreter with prompting and input buffering
πŸ“¦ Create InteractiveInterpreterInteractiveInterpreter(locals=None)Base class for parsing and interpreter state, no input buffering or prompting
πŸ“ Push a line to interpreterconsole.push(line)Append line to buffer and run; returns 1 if more input needed, 0 if complete

πŸ“š MODULE REFERENCE

https://docs.python.org/3.10/library/code.html

The following documentation is automatically generated from the Python source files. It may be incomplete, incorrect or include features that are considered implementation detail and may vary between Python implementations. When in doubt, consult the module reference at the location listed above.

πŸ›οΈ CLASSES

builtins.object
Β Β Β Β InteractiveInterpreter
Β Β Β Β Β Β Β Β InteractiveConsole

🧩 class InteractiveConsole

InteractiveConsole(locals=None, filename='<console>') β€” Closely emulate the behavior of the interactive Python interpreter. This class builds on InteractiveInterpreter and adds prompting using the familiar sys.ps1 and sys.ps2, and input buffering.

Method resolution order: InteractiveConsole, InteractiveInterpreter, builtins.object

πŸ”§ Methods defined here

⬅️ Methods inherited from InteractiveInterpreter

πŸ“¦ Data descriptors inherited from InteractiveInterpreter

🧩 class InteractiveInterpreter

InteractiveInterpreter(locals=None) β€” Base class for InteractiveConsole. This class deals with parsing and interpreter state (the user's namespace); it doesn't deal with input buffering or prompting or input file naming (the filename is always passed in explicitly).

πŸ”§ Methods defined here

πŸ“¦ Data descriptors defined here

πŸ”§ FUNCTIONS

πŸ”§ compile_command

compile_command(source, filename='<input>', symbol='single') β€” Compile a command and determine whether it is incomplete.

Arguments:

Return value / exceptions raised:

πŸ”§ interact

interact(banner=None, readfunc=None, local=None, exitmsg=None) β€” Closely emulate the interactive Python interpreter. This is a backwards compatible interface to the InteractiveConsole class. When readfunc is not specified, it attempts to import the readline module to enable GNU readline if it is available.

Arguments (all optional, all default to None):

πŸ“Š DATA

__all__ = ['InteractiveInterpreter', 'InteractiveConsole', 'interact',...]

πŸ“ FILE

/usr/lib/python3.10/code.py

code
πŸ“˜ NAME πŸš€ Quick Reference πŸ“š MODULE REFERENCE πŸ›οΈ CLASSES
🧩 class InteractiveConsole 🧩 class InteractiveInterpreter
πŸ”§ FUNCTIONS
πŸ”§ compile_command πŸ”§ interact
πŸ“Š DATA πŸ“ FILE

Generated by phpman v4.10.0-7-g98e9fd5 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-09-02 19:11 @216.73.216.239
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!

^_top_^