The Sage Input Hook#

This lets us perform actions while IPython is sitting at the terminal input prompt. We use it to reload attached files if they have changed.

sage.repl.inputhook.install()[source]#

Install the Sage input hook

EXAMPLES:

Make sure ipython is running so we really test this function:

sage: from sage.repl.interpreter import get_test_shell
sage: get_test_shell()
<sage.repl.interpreter.SageTestShell object at ...>
>>> from sage.all import *
>>> from sage.repl.interpreter import get_test_shell
>>> get_test_shell()
<sage.repl.interpreter.SageTestShell object at ...>

Run the function twice, to check it is idempotent (see Issue #35235):

sage: from sage.repl.inputhook import install
sage: install()
sage: install()
>>> from sage.all import *
>>> from sage.repl.inputhook import install
>>> install()
>>> install()
sage.repl.inputhook.sage_inputhook(context)[source]#
sage.repl.inputhook.uninstall()[source]#

Uninstall the Sage input hook

EXAMPLES:

sage: from sage.repl.inputhook import uninstall
sage: uninstall()
>>> from sage.all import *
>>> from sage.repl.inputhook import uninstall
>>> uninstall()