1

I just switched from R to Python, and find Jupyter Qt Console is really handy and helpful for running codes line by line.

But I have a question: how to save the codes already input? I mean just like Rstudio, the top left part is the code editor, the bottom left is the console window. So I can get a whole picture of my codes and debug them line by line.

I have tried Spyder(Rstudio like), but it has some problems in auto-completion. Qt console is much better. Is there a way to combine a text editor and qt console into one single IDE?

Thanks!

jijijude
  • 23
  • 4
  • It sounds like you don't know `jupyter notebook`? just type it in a terminal or on the command line. You can even save the notebooks and run them all at once. However, this is not an ide. What you might want to check out is the atom editor with the [hydrogen package](https://atom.io/packages/hydrogen) – Quickbeam2k1 Feb 20 '17 at 09:09
  • Thanks for the reply! Let me have it tried. Tks! – jijijude Feb 20 '17 at 10:14

1 Answers1

0

From the jupyter qtconsole you can use the %save magic to save your work. It's more cumbersome than I would like because you have to specify which input cells you want to save, but still quite handy.

For example, to save input cells 2 through 7 to a file called MyCommands.py, you simply type

%save MyCommands.py 2-7

Which will save the file in your current working directory. It'll even warn you and ask for confirmation if the file already exists.

For more information, use jupyter's extremely useful built-in help functionality by adding a question mark after the item you want help with.

%save?

Which prints the docstring

Docstring: Save a set of lines or a macro to a given filename.

Usage: %save [options] filename n1-n2 n3-n4 ... n5 .. n6 ...

Options:

-r: use 'raw' input. By default, the 'processed' history is used,
so that magics are loaded in their transformed version to valid
Python. If this option is given, the raw input as typed as the
command line is used instead. -f: force overwrite. If file exists, %save will prompt for overwrite unless -f is given.

-a: append to the file instead of overwriting it.

This function uses the same syntax as %history for input ranges, then saves the lines to the filename you specify.

It adds a '.py' extension to the file if you don't do so yourself, and it asks for confirmation before overwriting existing files.

If -r option is used, the default extension is .ipy. File:
~/anaconda3/lib/python3.5/site-packages/IPython/core/magics/code.py

Note that you can use the question mark to investigate any function or object with a docstring (i.e. enumerate?, range?).

saintsfan342000
  • 1,724
  • 1
  • 13
  • 16