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()#

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 ...>

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

sage: from sage.repl.inputhook import install
sage: install()
sage: install()
sage.repl.inputhook.sage_inputhook(context)#
sage.repl.inputhook.uninstall()#

Uninstall the Sage input hook

EXAMPLES:

sage: from sage.repl.inputhook import uninstall
sage: uninstall()