flow control in sage notebooks?
I would love to insert a break or stop command into sage files, in order to absolutly stop further processing. The interpreter (?) should not die or exit, but rather pretent to be done with the notebook.
I looked through the sage reference and didnt find something similar. actually i didnt find anything on the whole flow control topic.
You mentioned "sage files" so it's not clear: Do you mean like
.sage
scripts? Or a Jupyter notebook (that you're executing with "Run All Cells" or something)? In the latter case (which is nothing specific to Sage) there are several ways you could "pause" execution: Have a cell deliberate raise an exception. Put in atime.sleep()
(if you just want a temporary delay), put in a call toinput()
, etc.i mean bla.sage scripts, that i execute like "sage bla.sage". Is that also called sage notebook? or is that something else?
A
.sage
script is just a script. Just code saved to a file line-by-line for convenience so that you don't have to manually re-enter it manually into an interactive prompt. A notebook is another beast entirely. Sage is just Python so anything you can do in Python you can do in a Sage script. What exactly are you trying to do and why? What does "Pretend to be done with the notebook" mean to you, if not exit?I use sage-shell-mode in emacs. I dont want to do an exit, because then i would need to reload the sage process every time. I currently use the "syntax error break method" which makes the sage interpreter stop when it encounters a syntax error I insert deliberately - that is somewhat ugly, because it gives me two lines of traceback in emacs and interesting stuff is pushed out of my window. for my rapid work flow i would like something that just stops processing of my buffer at a given point - and pretends it is done, without an error or traceback.
I don't know anything about emacs so that would probably be a sage-shell-mode issue if it exits the interpreter when you're not otherwise done using it.