3 ms·
Don't overlook all of the % commands, such as %edit. If you are familiar with emacs keybindings, it has a very good built in editor as well. You can also load s
by bitexploder 8y ago
Don't overlook all of the % commands, such as %edit. If you are familiar with emacs keybindings, it has a very good built in editor as well. You can also load snippets from saved files, and save your history to a file. Or individual lines to files using range type expressions. In short it is very easy to get code in and out of IPython.
Another great trick. Anywhere you want to debug or play in your scripts run `import IPython` and the run `IPython.embed()` and your program at that point with all its locals drops into an IPython session, which is nice.
- IanCal 8y agoAs of 3.7 I think, you can use breakpoint() in your code and select the debugger you want with an environment variable, or enable/disable it without changing the code. https://www.python.org/dev/peps/pep-0553/ https://www.python.org/dev/peps/pep-0553/
- taeric 8y agoI'm not sure I would compare it favorably to emacs in pretty much anything other than mindshare. And, don't get me wrong, that is huge and not intended as a vanity comment. The keyboard shortcuts it has are superficial. My number one shortcuts in emacs are compile, jump to next error, grep/occur, index, and magic. Just up and down? Obviously u use them a lot, but the arrow keys do work fine. Beginning of line and begging of text are both huge. But really, the screwy tab behavior kills me in Jupyter.
- bitexploder 8y agoSure. The keybindings for the line editor are emacs like, but only surface level. I can often fix up a line quickly, whereas I notice the vi folks just use %edit. Jupyter, I only use when making plots and such. The one other super handy shortcut is CTRL-R for shell like reverse search. That is pretty sweet.
- kennedyp 8y agoYou can also leverage embed() within ipdb too and it can be nested. Very useful. Especially when combined with the ultratb or set_trace() from ipdb (or pdb): syntax is a little different dependant on whether you're in py3 or 2.7 so just google it but the jist of it is you replace the sys.excepthook with this colortb then when your script hits an uncaught exception say, you'll be presented with an ipdb colorised traceback. You can step up and down the stack frames, embedding at any point with `from IPython import embed` then `embed()` to get a fully functional ipython repl. game changer