Ask Your Question

Revision history [back]

Access notebook filename from jupyter with sagemath kernel

Say I am running sage in a jupyter notebook, e.g. invoked with sage -n jupyter my_nootebook_file.ipynb. After some computations I want to call a function from a custom library that stores all data in a file named my_nootebook_file.data.

I can do all the above manually, but I want the function to know that it is run inside the my_nootebook_file.ipynb notebook and hence the canonical output filename should be my_nootebook_file.*. How can I access this information? Shouldn't there be a "process information object" that should have all this information like current directory, ? I cannot seem to find it.

I did try

def outp(L):
    print [str(l) for l in L]
outp(locals())   

and searched the output for my notebook name, to no avail. Any hints are more than welcome.