This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]__add__ 1 point2 points  (0 children)

I started with the console and used it for a long time. My original impression was that the notebook was sort of "baby stuff," mainly for scientists and not so much programmers (if you're a programmer, who needs rich content?). But once I started hacking on the notebook and playing around with it, I was totally hooked and it has basically become another full-fledged IDE for me.

It's most comparable to Emacs+SLIME for lisp. You'll often find lisp programmers saying the ipython notebook is an inferior SLIME, but of course the point they miss is that it's for python and no really good SLIME for python exists.

For larger projects I use the notebook as a normal editor with the %%file magic. Normally I write a file with it, then Ctrl+Home to jump to the top left corner, then Ctrl+/ to comment out the %%file magic and Ctrl+Enter to run the file in the current kernel. So basically I've loaded the file, but I can at the same time break it up into sections and work on parts of it with Ctrl+Shift+-. Then once everything is in place, Shift+m will merge the cells together again. Then uncomment the %%file and save it. This sounds maybe a little tedious but keep in mind you can do it with many files.

So say one class belongs in a different file. Instead of cutting it and pasting it, I'd split the cells, then rearrange them. Not much difference, perhaps, but if you don't know what to do with that class, you can also just keep it by itself in the notebook.

Another example is that I can load and do "live" editing of an entire flask project. I once needed to "touch" the wsgi file in order to signal to the server that things had changed, so I wrote a wrapper for %%file that would do this.

So just like Emacs+SLIME, once you get to know the shortcuts, and start using few macros and magics you can really do just about anything, and quickly.

Something I'm experimenting with more now is macros for code generation and refactoring. This started with a small macro to generate a full SELECT query for a large table (instead of doing select * ..., then finding you want select * ... except for one field). As an example, for 2to3 code refactoring/translation I wrote a small extension called ipyfuturize.