Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I had a similar issue dealing with the preparser so I wrote an IPython extension which adds a cell magic %%noparse which disables the Sage preparser for the cell its applied to.

Save this code as

from IPython.core.magic import (Magics, magics_class, cell_magic)

import sage.repl.interpreter

class NoParseMagic(Magics):

    def noparse(self, line, cell):
        Use this cell magic to disable Sage preparsing in an IPython cell.
        sage.repl.interpreter._do_preparse = False
        sage.repl.interpreter._do_preparse = True

def load_ipython_extension(ipython):

If you like, you can copy this to .ipython/extensions/. Then in a Sage Jupyter notebook, you can run:

%load_ext noparse

to load the extension. Now the following works:


which yields:

<type 'int'>

instead of:

<type 'sage.rings.integer.Integer'>