I have a function in sage I want to save, but I cannot figure out how. I'm running sage on a mac through the terminal. I'm finding stuff online about save_session, or saving to a document.sage file or something but nothing really seems to be working, is there a straightforward way to do this? Thanks.
Edit: Also while I have your attention, say you have a function f, how do you display the contents of f without actually running it?
asked Mar 12 '12
I think the answer crucially depends on what you mean by the word "function".
It could be a Python or Cython function, either defined in an interactive session or in a module. It could be a symbolic expression, or perhaps could be a polynomial, which are sometimes mistaken for a function.
Symbolic function is easy to pickle:
Similarly, a polynomial is easy to pickle:
However, if you are really talking about a Python function (e.g., a lambda function), then there is a general problem: You can't easily pickle Python functions defined in an interactive session. And Python is Sage's programming language.
However, if you define the same function in some Python module, then pickling would work.
And what do you mean by the "contents" of a function?
Do you mean, you have a Python function and want to see its code?
Then again, if it is defined in a module, then it works easily: If you have any object
But if the function is only defined in an interactive session, then Python can not find the code.
posted Mar 12 '12Simon King
376 ● 2 ● 11
Asked: Mar 12 '12
Seen: 326 times
Last updated: Mar 14 '12
powered by ASKBOT version 0.7.22
Copyright Sage, 2010. Some rights reserved under creative commons license.