Initiating ipython shell in terminal
Initiating Jupyter notebook in terminal
To get the source code
Both of this even works for the functions that you have created.
Tab completion is awesome.
Tab completion is great in conjunction with
from pandas import <tab> and
import <tab> to list out the objects and libraries.
? for wildcard matching.
ctrl + u copy from beginning,
ctrl + y paste
ctrl + p previous command in history,
ctrl + r history command
ctrl + l clear,
ctrl + d Exit
%paste paste without indentation problem
%run test.py run a .py file in the same folder, and functions of that file is now available in the shell, and you can call them.
%timeit for single line execution, and
%%timeit for multiline codes.
%lsmagic to get a list of magic functions.
Everything you input is stored in
In which is a list (Input number is index number) and Everything you output is stored in
Out as a dictionary (Output number is Key).
For easy access to output use
print(_), 1 underscore is the last one, 2 underscore as in
print(__) for the 2nd last
Out or output result.
for not displaying an output end the statement with a semicolon.
%history -n 1-4 return history input,
-n for index number,
1-4 for limiting the return statement.
shell commands work in ipython by prefixing them with
We can also assign variables to the output of this ipython shell commands i.e.
files = !ls, which returns a special kind of list.
You can also use python variables as shell variables by using
cd by magic command
%cd or simply
cd. This works for every shell command.
%xmode limits the exception (/error) message.
%xmode takes a single argument of the three,
Verbose(More information). i.e.
python’s standard debugger
pdb, and ipython's is
ipdb. We enter into debugging with
%debug. Then start giving commands (
type etc.) to check, and
To run a file in debugging mode
%run -d test.py
In the debugger
help <specific command>.
This summary is based on the book Python Data Science Handbook by Jake VanderPlas