I am curious to see the general workflow expanded on. I hesitate to think there is a single correct way to keep a notebook. Seems flexibility is the key feature. And is why text is so well used.
I am curious to see the general workflow expanded on. I hesitate to think there is a single correct way to keep a notebook. Seems flexibility is the key feature. And is why text is so well used.
The only thing I would like is to be able to use the Python interpreter _within_ the context of a function sometimes, it's annoying when an error occurs inside a function and I can't access the local variables.
I like jupyter notebooks too, but one of the things stopping me is that I can't use emacs features for editing ;)
import IPython; IPython.embed()
though IPython kinda doesn't clean up after itself, so it's a bit messier (your prompt is messed up afterwards).Finally, you can:
import code; code.interact()
The downside of this is there's no history or autocomplete by default.I have a custom function `embed()` [1] that calls `code.interact()`, but with history and autocomplete configured. This is the closest I got it to looking like a regular Python interpreter at an arbitrary place in the code.
In any case I think there was a way to examine variables from up the stack of a stack trace or something like that.. bit too lazy to look it up right now. Regardless, working with a REPL in emacs is pretty great ;)
I think there is a way to do jupyter from emacs (or at least there was a way to do ipython notebooks), but I haven't used it extensively, just tested it once I think. I guess I'm pretty satisfied with the REPL and haven't found a need to have intermediate output during the running of a program.
What I do like about the matpotlib interactive approach is being able to watch the progress of a loop very easily, which is hard to do from a notebook, although there are some ways, but they are either hacky or require some pretty sophisticated things like custom widgets.
So I just add a try: except around code known to be crashing and call my `embed()` function on except. This has served me well enough that I haven't bothered with anything else.
Plus, if I really want to inspect unplanned crashes, I would want to be able to get them when running, and not just developing, the app. So there might not even be a terminal - there are more complications than just 'not having to declare where you think it will crash', so I don't think I'll bother solving the more specific problem unless it would help me debug unexpected crashes in a broader context.
https://stackoverflow.com/questions/4234612/launch-an-ipytho...
This gives you a pdb prompt not an IPython prompt, but you can examine local variables where the exception was raised, and exit back to IPython with Ctrl-D.
[1https://github.com/millejoh/emacs-ipython-notebook/blob/mast...