Ask Your Question

Revision history [back]

IMHO worksheets are good for some rapid prototyping, but what you talk about, essentially, developing your own mini-library of functions, is better done in shell.


What you can do anyway, if you control the Sage installation, is adding the Sage code you want to share between worksheets somewhere to Sage library. E.g. suppose you added a Python function my_blahblah to the file $SAGEROOT/devel/sage/sage/matrix/constructor.py Then you run sage -b to rebuild the library, and after that it is there:

sage: from sage.matrix.constructor import my_blahblah
sage: my_blahblah()
'foo'

If you want to have it available without importing, you can add this import statement to $SAGEROOT/devel/sage/sage/matrix/all.py, then this new function will be known right from the start of Sage.