Ask Your Question

How to save my work locally

asked 2017-02-17 04:00:26 -0500

python_15 gravatar image


I'm new with SageMath, but after some days reading and working I'm quite familiar with the main concepts, so working in the terminal an the notebook isn't a problem for me now. The problem I have is: How can I save the code I wrote locally, in a .sage-file on my drive or something like that? How can I organize my work well?

I haven't fount anything in tutorials, maybe someone could give me an explanation or a useful link! (:

Thanks a lot, python_15

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2017-02-17 08:09:13 -0500

tmonteil gravatar image

updated 2017-02-17 08:11:02 -0500

From the command line, you can define your classes/functions/variables within a my_file.sage and attach it to your session by typing:

sage: %attach /path/to/my_file.sage

and then, the file is executed. It is re-executed each time you save the file, so that you do not have to re-load it again.

If you do not want the sage preparser to take effect so that your file is understood as a python file, you should name your file

edit flag offensive delete link more

answered 2017-03-09 03:09:54 -0500

I prefer to use the jupyer notebook for exactly this purpose. If you invoke sage -n jupyter in a local directory, say ~/Documents/Analysis_Problems/, you can generate notebooks and they automatically correspond to files in your local directory. This works great in combination with version control systems like git. You can also call sage -n jupyter <filename> to open a specific notebook file from the command line. The best thing is that jupyter files are text files and that they are not limited to sage, but you can also have them with kernels for various other languages.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2017-02-17 04:00:26 -0500

Seen: 44 times

Last updated: Mar 09