IPython is a neat alternative of Python's builtin REPL (Read–Eval–Print Loop) interpreter, also a kernel of Jupyter.
# cheatsheet %quickref # show details of any objects (including modules, classes, functions and variables) random? os.path.join? some_variable? # show source code of any objects os.path.join?? # show nothing for a function that is not implemented in Python len?? # run some shell commands directly in IPython pwd ll cd cp rm mv mkdir new_folder # run any shell command with ! prefix !ls !ping www.google.com !youtube-dl # assign command output to a variable contents = !ls print(contents)
# list all magic functions %lsmagic # run a Python script and load objects into current session %run my_script.py # run a profiling for multi-line code %%timeit array =  for i in xrange(100): array.append(i) # paste multi-line code # you might not need them in IPython 5.0+, just paste your code %cpaste # explore objects %pdoc some_object %pdef some_object %psource some_object %pfile some_object # if you call it after hitting an exception, it will automatically open ipdb at the point of the exception %debug # the In object is a list which keeps track of the commands in order print(In) # the Out object is a dictionary mapping input numbers to their outputs pinrt(Out) print(Out, _2)
Reload Any Python Module
from your.project import your_module your_module.run_shit(123) # after you made some changes on your_module from importlib import reload reload(your_module) your_module.run_shit(123)