codecs.Codec.encode()

Codec.encode(input[, errors]) Encodes the object input and returns a tuple (output object, length consumed). For instance, text encoding converts a string object to a bytes object using a particular character set encoding (e.g., cp1252 or iso-8859-1). The errors argument defines the error handling to apply. It defaults to 'strict' handling. The method may not store state in the Codec instance. Use StreamWriter for codecs which have to keep state in order to make encoding efficient. The encod

codecs.Codec.decode()

Codec.decode(input[, errors]) Decodes the object input and returns a tuple (output object, length consumed). For instance, for a text encoding, decoding converts a bytes object encoded using a particular character set encoding to a string object. For text encodings and bytes-to-bytes codecs, input must be a bytes object or one which provides the read-only buffer interface – for example, buffer objects and memory mapped files. The errors argument defines the error handling to apply. It defaul

codecs.backslashreplace_errors()

codecs.backslashreplace_errors(exception) Implements the 'backslashreplace' error handling (for text encodings only): malformed data is replaced by a backslashed escape sequence.

code.InteractiveInterpreter.write()

InteractiveInterpreter.write(data) Write a string to the standard error stream (sys.stderr). Derived classes should override this to provide the appropriate output handling as needed.

code.InteractiveInterpreter.showtraceback()

InteractiveInterpreter.showtraceback() Display the exception that just occurred. We remove the first stack item because it is within the interpreter object implementation. The output is written by the write() method. Changed in version 3.5: The full chained traceback is displayed instead of just the primary traceback.

code.InteractiveInterpreter.showsyntaxerror()

InteractiveInterpreter.showsyntaxerror(filename=None) Display the syntax error that just occurred. This does not display a stack trace because there isn’t one for syntax errors. If filename is given, it is stuffed into the exception instead of the default filename provided by Python’s parser, because it always uses '<string>' when reading from a string. The output is written by the write() method.

code.InteractiveInterpreter.runsource()

InteractiveInterpreter.runsource(source, filename="", symbol="single") Compile and run some source in the interpreter. Arguments are the same as for compile_command(); the default for filename is '<input>', and for symbol is 'single'. One several things can happen: The input is incorrect; compile_command() raised an exception (SyntaxError or OverflowError). A syntax traceback will be printed by calling the showsyntaxerror() method. runsource() returns False. The input is incomplete, an

code.InteractiveInterpreter.runcode()

InteractiveInterpreter.runcode(code) Execute a code object. When an exception occurs, showtraceback() is called to display a traceback. All exceptions are caught except SystemExit, which is allowed to propagate. A note about KeyboardInterrupt: this exception may occur elsewhere in this code, and may not always be caught. The caller should be prepared to deal with it.

code.InteractiveInterpreter

class code.InteractiveInterpreter(locals=None) This class deals with parsing and interpreter state (the user’s namespace); it does not deal with input buffering or prompting or input file naming (the filename is always passed in explicitly). The optional locals argument specifies the dictionary in which code will be executed; it defaults to a newly created dictionary with key '__name__' set to '__console__' and key '__doc__' set to None.

code.InteractiveConsole.resetbuffer()

InteractiveConsole.resetbuffer() Remove any unhandled source text from the input buffer.