IPython
IPython
It’s an interpreter with the most features. It has many features which includes parallel computing, integrations with visual toolkits, interactive widgets, and a web-based interpreter (Jupyter).
Installing IPython
You can install IPython using pip:
pip install ipython
# or
conda install ipython
Introspection and Help
The ?
character can be used to get help on objects. For example, object?
will display the docstring for that object.
It can be either used as a prefix or a suffix.
The ??
character can be used to get the source code of the object.
Auto-Completion
IPython provides auto-completion for objects and modules. You can use the Tab
key to complete the code.
Seeing command History
You can view your past commands by typing %history
in the IPython shell.
LaTeX Support
from IPython import display
display.Math(r'\int_0^\infty e^{-x^2} dx')
Interactive Widgets
import ipywidgets
def square(x):
return x * x
ipywidgets.interact(square, x=10)
Magic Commands
IPython provides a set of magic commands that allow you to control the behavior of the IPython shell. Magic commands are prefixed with %
or %%
.
%quickref
- Display the IPython quick reference.%cd
- Change the current working directory of the ipython session.%paste
- Execute preformatted code from the clipboard.%edit
- Open an editor to write.%timeit
- Time the execution of a Python statement or expression.?
- Get help on an object or function.??
- Show the source code of an object or function.