Jupyter with IPython
IPython is a much better interactive command line interface for Python than the default Python Shell. It supports variable auto-completion, auto-indentation, Bash Shell commands, and has many useful built-in functions and features. Greatly improves the productivity of interactive computing and software development.
Jupyter Notebook (formerly IPython Notebook) is a web-based interactive computing environment for creating Jupyter Notebook documents.Notebook is a web based IPython wrapper that makes it possible to use IPython in the browser. Thanks to the web-side data and presentation separation model and the rich text feature, Notebook can take IPython’s data presentation capabilities, which are limited by the command line, and make them fully accessible through the browser.
In 2014, Fernando PĂ©rez announced the derivation of a project from IPython called Jupyter. IPython continued to exist as the Python shell and the Jupyter kernel, while IPython Notebook and other language-independent parts were moved to the Jupyter name. Jupyter is language-agnostic, and its name is a reference to the kernel programming languages supported by Jupyter, which are Julia, Python, and R. It supports the execution environments (that is, the kernel) of dozens of languages (page archive backups, stored in the Internet Archive), which include Julia, R, Haskell, Ruby, and of course Python (via the IPython kernel).
IPython magic commands
IPython provides a number of magic commands that make operating in the IPython environment more comfortable. The magic commands all start with % or %%. Those starting with % become line commands, and those starting with %% are called unit commands. Line commands are only valid for the line where the command is located, while unit commands must appear on the first line of the unit and process the entire unit of code.
Execute %lsmagic to see the description about each command, and add ? to see a detailed description of the command.
|
|
Common magic commands.
- %magic shows detailed documentation of all magic commands
- %time statement reports the execution time of a statement.
- %timeit statement Execute the statement multiple times to calculate the average execution time
- %prun statement Execute the statement via cProfile and print the parser results.
- %run
script.py
Execute an external script file in ipython. - %pdb automatically counts to the debugger after an exception is thrown.
- %hist Query the history of input.
- %debug Accesses the interactive debugger from the bottom of the latest exception trace.
- %env Display system environment variables.
- %reset Clear namespace
- %cd Enter directory command