digraph InheritanceGraph { graph [bgcolor=transparent, color=lightsteelblue2, fontname=Arial, fontsize=10, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, splines=spline, style="dashed, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=10, height=0, penwidth=2, shape=box, style="filled, rounded", width=0]; edge [color=lightslategrey, penwidth=1]; subgraph "cluster_abjadext.book" { graph [label="abjadext.book"]; node [color=1]; "abjadext.book.AbjadBookConsole.AbjadBookConsole" [URL="../api/abjadext/book/AbjadBookConsole.html#abjadext.book.AbjadBookConsole.AbjadBookConsole", color=black, fontcolor=white, label="Abjad\nBook\nConsole", target=_top]; } subgraph cluster_builtins { graph [label=builtins]; node [color=2]; "builtins.object" [URL="https://docs.python.org/3.6/library/functions.html#object", label=object, target=_top]; } subgraph cluster_code { graph [label=code]; node [color=3]; "code.InteractiveConsole" [URL="https://docs.python.org/3.6/library/code.html#code.InteractiveConsole", label="Interactive\nConsole", target=_top]; "code.InteractiveInterpreter" [URL="https://docs.python.org/3.6/library/code.html#code.InteractiveInterpreter", label="Interactive\nInterpreter", target=_top]; "code.InteractiveInterpreter" -> "code.InteractiveConsole"; } "builtins.object" -> "code.InteractiveInterpreter"; "code.InteractiveConsole" -> "abjadext.book.AbjadBookConsole.AbjadBookConsole"; }

class abjadext.book.AbjadBookConsole.AbjadBookConsole(document_handler=None, locals=None, filename='<stdin>')

An interactive console which provides a sandboxed namespace for executing abjad-book code examples.

Attributes Summary

errored Is true if the last line executed by the console errored.
restore_topleveltools_dict Restores the topleveltols module dictionary.
save_topleveltools_dict Caches the dictionary of the topleveltools module.
showsyntaxerror Proxies Python’s InteractiveConsole.showsyntaxerror().
showtraceback Proxies Python’s InteractiveConsole.showtraceback().
unregister_error Unregisters the last error registered in the current document handler.


(InteractiveConsole).interact(banner=None, exitmsg=None)

Closely emulate the interactive Python console.

The optional banner argument specifies the banner to print before the first interaction; by default it prints a banner similar to the one printed by the real Python interpreter, followed by the current class name in parentheses (so as not to confuse this with the real interpreter – since it’s so close!).

The optional exitmsg argument specifies the exit message printed when exiting. Pass the empty string to suppress printing an exit message. If exitmsg is not given or None, a default message is printed.


Push a line to the interpreter.

The line should not have a trailing newline; it may have internal newlines. The line is appended to a buffer and the interpreter’s runsource() method is called with the concatenated contents of the buffer as source. If this indicates that the command was executed or invalid, the buffer is reset; otherwise, the command is incomplete, and the buffer is left as it was after the line was appended. The return value is 1 if more input is required, 0 if the line was dealt with in some way (this is the same as runsource()).


Write a prompt and read a line.

The returned line does not include the trailing newline. When the user enters the EOF key sequence, EOFError is raised.

The base implementation uses the built-in function input(); a subclass may replace this with a different implementation.


Reset the input buffer.


Restores the topleveltols module dictionary.


Execute a code object.

When an exception occurs, self.showtraceback() is called to display a traceback. All exceptions are caught except SystemExit, which is reraised.

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.

(InteractiveInterpreter).runsource(source, filename='<input>', symbol='single')

Compile and run some source in the interpreter.

Arguments are as for compile_command().

One several things can happen:

1) The input is incorrect; compile_command() raised an exception (SyntaxError or OverflowError). A syntax traceback will be printed by calling the showsyntaxerror() method.

2) The input is incomplete, and more input is required; compile_command() returned None. Nothing happens.

3) The input is complete; compile_command() returned a code object. The code is executed by calling self.runcode() (which also handles run-time exceptions, except for SystemExit).

The return value is True in case 2, False in the other cases (unless an exception is raised). The return value can be used to decide whether to use sys.ps1 or sys.ps2 to prompt the next line.


Caches the dictionary of the topleveltools module.

Because CodeBlock replaces various topleveltools function references with its own proxies, the originals must be cached so they can later be restored. Otherwise Sphinx’s autodoc extension will discover the abjad-book function proxies and not the originals.


Proxies Python’s InteractiveConsole.showsyntaxerror().


Proxies Python’s InteractiveConsole.showtraceback().


Unregisters the last error registered in the current document handler.

This occurs when the interpreting code block permits errors to appear.


Write a string.

The base implementation writes to sys.stderr; a subclass may replace this with a different implementation.

Read-only properties


Is true if the last line executed by the console errored.