ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 01 Jul 2022 16:54:10 +0200create a file with .sage extensionhttps://ask.sagemath.org/question/63071/create-a-file-with-sage-extension/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!Thu, 30 Jun 2022 19:11:05 +0200https://ask.sagemath.org/question/63071/create-a-file-with-sage-extension/Comment by 1571 for <p>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?</p>
<p>Thanks!</p>
https://ask.sagemath.org/question/63071/create-a-file-with-sage-extension/?comment=63074#post-id-63074Which one? The ones I have on macbook (texshop, visual code studio and textedit) do not allow this extension.Thu, 30 Jun 2022 20:36:04 +0200https://ask.sagemath.org/question/63071/create-a-file-with-sage-extension/?comment=63074#post-id-63074Comment by John Palmieri for <p>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?</p>
<p>Thanks!</p>
https://ask.sagemath.org/question/63071/create-a-file-with-sage-extension/?comment=63073#post-id-63073Use a text editor.Thu, 30 Jun 2022 20:05:34 +0200https://ask.sagemath.org/question/63071/create-a-file-with-sage-extension/?comment=63073#post-id-63073Answer by slelievre for <p>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?</p>
<p>Thanks!</p>
https://ask.sagemath.org/question/63071/create-a-file-with-sage-extension/?answer=63084#post-id-63084## 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:
- [post on "jupyter" mailing list: Syntax highlighting for text files in Jupyter Notebook and JupyterLab](https://groups.google.com/g/jupyter/c/G_euKH35vU0/)
- [Jupyter Discourse post 5186: Syntax highlighting for text files in Jupyter Notebook and JupyterLab](https://discourse.jupyter.org/t/syntax-highlighting-for-text-files-in-jupyter-notebook-and-jupyterlab/5186)
### Other text editors
Other text editor options are listed at
- [Sage Trac ticket 30500: Meta-ticket: document configuring IDEs and text editors](https://trac.sagemath.org/ticket/30500)
with links to configuration instructions for some text editors or IDEs.Fri, 01 Jul 2022 16:54:10 +0200https://ask.sagemath.org/question/63071/create-a-file-with-sage-extension/?answer=63084#post-id-63084Answer by John Palmieri for <p>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?</p>
<p>Thanks!</p>
https://ask.sagemath.org/question/63071/create-a-file-with-sage-extension/?answer=63076#post-id-63076Use 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>`Thu, 30 Jun 2022 22:43:43 +0200https://ask.sagemath.org/question/63071/create-a-file-with-sage-extension/?answer=63076#post-id-63076Comment by John Palmieri for <p>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.</p>
<p>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). <code><flamewar></code>Emacs is of course the best.<code></flamewar></code></p>
https://ask.sagemath.org/question/63071/create-a-file-with-sage-extension/?comment=63078#post-id-63078Perhaps `<religiouswar>` tags? ;) Cheers, regardless!Fri, 01 Jul 2022 00:59:51 +0200https://ask.sagemath.org/question/63071/create-a-file-with-sage-extension/?comment=63078#post-id-63078Comment by Emmanuel Charpentier for <p>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.</p>
<p>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). <code><flamewar></code>Emacs is of course the best.<code></flamewar></code></p>
https://ask.sagemath.org/question/63071/create-a-file-with-sage-extension/?comment=63077#post-id-63077No 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](https://github.com/sagemath/sage-shell-mode) and you have one of the best IDEs fpr Sage interaction.
- Add [org-mode](https://www.orgmode.org/) and [ob-sagemath](https://github.com/sagemath/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](https://github.com/sagemath/sagetex) and [AUCTeX](https://www.gnu.org/software/auctex/).
I could go on...Thu, 30 Jun 2022 23:15:29 +0200https://ask.sagemath.org/question/63071/create-a-file-with-sage-extension/?comment=63077#post-id-63077