Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Import custom sage libraries into a Jupyter notebook

What is the correct way to write and import custom SAGE libraries into a jupyter notebook?

When using jupyter notebooks with a python kernel, importing your own python library is as easy as saving a file foo.py in the same directory as the notebook and putting animport foo line in the notebook. Using a SAGE kernel, I can import foo.py into my notebook, but without the ability to call SAGE methods: e.g. calling the function

def monty(n): return SymmetricGroup(n)

from foo.py gives the error,

NameError: global name 'SymmetricGroup' is not defined

My desired workflow: work in a notebook for convenience but be able to pass on what I've done in the form of a library.