Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

There is no simple solution with the Sage notebook. You can save your worksheet as an .sws file and then from the command line do sage -sws2rst your_worksheet.sws to get an rst file, so that it is easier to post-process the text file to obtain a genuine Python file (this can then easily be done sine you just have to select lines that start either with <space><space><space><space>sage:<space> or with <space><space><space><space>...<space><space>).

It is easier with the jupyter notebook:

  • If you want a short notebook, you can clean all output by clicking on "Kernel" then "Restart & clear output". Then you can save your worksheet that only contains input cells (the cells with your code).
  • You can also get those input cells in a Python file by clicking on "Flie", then "Download as", then "Python (.py)".
click to hide/show revision 2
No.2 Revision

There is no simple solution with the Sage notebook. You can save your worksheet as an .sws file and then from the command line do sage -sws2rst your_worksheet.sws to get an rst file, so that it is easier to post-process the text file to obtain a genuine Python file (this can then easily be done sine since you just have to select lines that start either with <space><space><space><space>sage:<space> or with <space><space><space><space>...<space><space>).

It is easier with the jupyter notebook:

  • If you want a short notebook, you can clean all output by clicking on "Kernel" then "Restart & clear output". Then you can save your worksheet that only contains input cells (the cells with your code).
  • You can also get those input cells in a Python file by clicking on "Flie", then "Download as", then "Python (.py)".