Ask Your Question
1

Using SAGE from an editor

asked 2017-12-22 06:26:39 +0100

I was wondering if there is a way to use SAGE in an editor like I can with the Python GUI Idle. I only know how to run it using the terminal or the ntoebook, but if I want to write a lengthy program in SAGE involving several files, I need to start using attach, which is bothersome.

I'm using SAGEmath 8.1 for Windows and Windows 10. I have also Notepad++ in case it helps. I am willing to install any editor that works painlessly with SAGE but I'd rather not use EMACS/Vim. Too many bad memories from college.

edit retag flag offensive close merge delete

Comments

@Iguananaut's answer to this similar question https://ask.sagemath.org/question/39742/make-pycharm-recognise-the-sage-python-interpreter/ might also answer your question.

slelievre gravatar imageslelievre ( 2017-12-26 20:08:52 +0100 )edit

One thing you'll find is that Sage has syntax that is almost but not quite Python--that is, Sage has its own special syntactic extensions to Python. So any editor that supports syntax highlighting for Python will be mostly fine for Sage, but not quite, though I believe people have implemented Sage syntax highlighting for a few different editors--not sure if there's a list of that somewhere. Beyond that though, I'm not sure what you mean by "painless"--you'd have to be more specific. I don't know why you think you need to use attach. If you want to write a complex program involving multiple files you can gather them up into a normal Python package. Now, how to organize a multiple-module Python package is another question, but a skill worth learning.

Iguananaut gravatar imageIguananaut ( 2018-01-05 16:04:35 +0100 )edit

Regarding your files as a Python package, see also:

slelievre gravatar imageslelievre ( 2018-01-07 00:43:15 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-12-26 12:06:26 +0100

Emmanuel Charpentier gravatar image

Full disclosure : I have fiddled with computer since 1974. I got my first contact with emacs in 1986 and used it almost exclusively for "hard" editing since about 1990. Therefore, I am obviously biased.

I am not aware of an editor able to "run" sage other than... emacs (via sage_shell_mode).

Before you run away screaming, I have to tell you that sage_shell_mode is really a very nice piece of work, making the development of a complicated work (such as a paper draft) a breeze :

  • Using sage in emacs is a nice replacement for the IPython console. Getting your math (properly) typeset and your (2D) graphs in the main window is damn useful.

  • Using a buffer for editing your code, then sending it to Sage with two keystrokes severely reduces the development time. And you don't have to worry about code formattong (capital for Python and Python-like languages, since wite space is syntaxically importan !) : the editor will manage it for you.

  • Using sage_shell_mode + SageTeX + AUCTeX (a very nice \LaTeX mode for emacs) is, IMNSHO, the only realistic way to produce a good paper (avoiding the troubles you are certain to experience using manual cut'n_paste, for example).

Yes, emacs has a learning curve similar to the Matterhorn (only a bit steeper...:-). Hence your bad-memories-from-college, probably worsened by the time pressure you suffered then (you need _time_ to grok emacs...).

But it's really worth it. Try perusing the emacs tutorial (standard in all emacs installations), ignoring the outdated bits such as control character for small cursor moves (the moves by paragraph, section, etc... are still relevant)). And give yourself the necessary time to "drink" the process (a couple weeks ?).

Then, try to compare the time necessary to real program editing with emacs and your current favorite editor. I'd be surprised if emacs didn't come ahead by a huge margin...

[Obligatory holy wars comparison ;-] Notepad++ ? Bah... And don't get me started on vi(le)...

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

Stats

Asked: 2017-12-22 06:26:39 +0100

Seen: 2,234 times

Last updated: Dec 26 '17