Ask Your Question
1

create a file with .sage extension

asked 2022-06-30 19:11:05 +0200

1571 gravatar image

updated 2022-06-30 19:11:32 +0200

Hello, In order to use the load() function in sage, the file I want to load needs to be a .sage extension. When I create a new sage worksheet on my computer's SAGE notebook, it creates a .ipynb extension. How can I create a .sage extension instead?

Thanks!

edit retag flag offensive close merge delete

Comments

1

Use a text editor.

John Palmieri gravatar imageJohn Palmieri ( 2022-06-30 20:05:34 +0200 )edit

Which one? The ones I have on macbook (texshop, visual code studio and textedit) do not allow this extension.

1571 gravatar image1571 ( 2022-06-30 20:36:04 +0200 )edit

2 Answers

Sort by ยป oldest newest most voted
2

answered 2022-07-01 16:54:10 +0200

slelievre gravatar image

updated 2022-07-02 10:50:32 +0200

Creating a .sage file

Creating a .sage file should work in any text editor.

One challenge is then how to configure the text editor to apply Python syntax highlighting to it.

In Jupyter Notebook or JupyterLab

In Jupyter Notebook, the "New" pop-down menu offers

  • "Notebook" with the various Jupyter kernels available
  • Other, including: "Text File", "Folder", "Terminal"

so one can select "Text File" and name it with the extension .sage.

In JupyterLab, the launcher offers an option to create a text file.

In both cases, one would like to apply Python syntax highlighting to .sage files.

Not sure how to do that though; I asked here but got no answer:

Other text editors

Other text editor options are listed at

with links to configuration instructions for some text editors or IDEs.

edit flag offensive delete link more
3

answered 2022-06-30 22:43:43 +0200

updated 2022-06-30 22:44:58 +0200

Use a text editor. If you use Visual Code Studio, I suggest choosing Python for the language for the file, and then when you save it, call it "whatever.sage". If you use TextEdit, then choose the "plain text" format when editing, in which case it will automatically get a ".txt" extension when you save it. You can then rename it using the Terminal, or from the Finder, select the file and from the File menu, choose "Get Info". There will be a box for "Name & Extension", and you can remove the ".txt" extension using that.

You can also use Emacs or VIM, maybe BBEdit (although I haven't used that in years). Maybe Sublime Text (although it's not free). <flamewar>Emacs is of course the best.</flamewar>

edit flag offensive delete link more

Comments

No need to add flamewar tags. Emacs is, of course, the right editor. But also a very good working environment for a lot of tasks :

  • Add it sage-shell-mode and you have one of the best IDEs fpr Sage interaction.

  • Add org-mode and ob-sagemath and you get a very good document preparation system, able to export to almost anything (from .docx to HTML.

  • If you need publication quality LaTeX, use SageTeX and AUCTeX.

I could go on...

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2022-06-30 23:15:29 +0200 )edit

Perhaps <religiouswar> tags? ;) Cheers, regardless!

John Palmieri gravatar imageJohn Palmieri ( 2022-07-01 00:59:51 +0200 )edit

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 2022-06-30 19:11:05 +0200

Seen: 520 times

Last updated: Jul 02 '22