First time here? Check out the FAQ!

Ask Your Question
1

create a file with .sage extension

asked 2 years ago

1571 gravatar image

updated 2 years ago

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!

Preview: (hide)

Comments

1

Use a text editor.

John Palmieri gravatar imageJohn Palmieri ( 2 years ago )

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

1571 gravatar image1571 ( 2 years ago )

2 Answers

Sort by » oldest newest most voted
2

answered 2 years ago

slelievre gravatar image

updated 2 years ago

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.

Preview: (hide)
link
3

answered 2 years ago

updated 2 years ago

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>

Preview: (hide)
link

Comments

1

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 ( 2 years ago )

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

John Palmieri gravatar imageJohn Palmieri ( 2 years ago )

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: 2 years ago

Seen: 945 times

Last updated: Jul 02 '22