Beginning Programming with Python For Dummies
Book image
Explore Book Buy On Amazon
Jupyter Notebook relies on the literate programming approach originally advanced by Donald Knuth. This means that the Integrated Development Environment (IDE) produces output that looks more like a report than the complex coding environments that most people rely on. The magic functions add to this capability by creating an environment in which you can choose something other than the expected result. The following table highlights the most important magic functions that Jupyter Notebook provides.
Magic Function Type Alone Provides Status? Description
%alias Yes Assigns or displays an alias for a system command.
%autocall Yes Enables you to call functions without including the parentheses. The settings are Off, Smart (default), and Full. The Smart setting applies the parentheses only if you include an argument with the call.
%automagic Yes Enables you to call the line magic functions without including the % sign. The settings are False (default) and True.
%autosave Yes Displays or modifies the intervals between automatic Notebook saves. The default setting is every 120 seconds.
%cd Yes Changes directory to a new storage location. You can also use this command to move through the directory history or to change directories to a bookmark.
%cls No Clears the screen.
%colors No Specifies the colors used to display text associated with prompts, information system, and exception handlers. You can choose between NoColor (black and white), Linux (default), and LightBG.
%config Yes Enables you to configure IPython.
%dhist Yes Displays a list of directories visited during the current session.
%file No Outputs the name of the file that contains the source code for the object.
%hist Yes Displays a list of magic function commands issued during the current session.
%install_ext No Installs the specified extension.
%load No Loads application code from another source, such as an online example.
%load_ext No Loads a Python extension using its module name.
%lsmagic Yes Displays a list of the currently available magic functions.
%magic Yes Displays a help screen showing information about the magic functions.
%matplotlib Yes Sets the backend processor used for plots. Using the inline value displays the plot within the cell for an IPython Notebook file. The possible values are gtk'; 'gtk3'; 'inline'; 'nbagg'; 'osx'; 'qt'; 'qt4'; 'qt5'; 'tk'; and 'wx'.
%paste No Pastes the content of the Clipboard into the IPython environment.
%pdef No Shows how to call the object (assuming that the object is callable).
%pdoc No Displays the docstring for an object.
%pinfo No Displays detailed information about the object (often more than is provided by help alone).
%pinfo2 No Displays extra detailed information about the object (when available).
%reload_ext No Reloads a previously installed extension.
%source No Displays the source code for the object (assuming that the source is available).
%timeit No Calculates the best performance time for an instruction.
%%timeit No Calculates the best time performance for all the instructions in a cell, apart from the one placed on the same cell line as the cell magic (which could therefore be an initialization instruction).
%unalias No Removes a previously created alias from the list.
%unload_ext No Unloads the specified extension.
%%writefile No Writes the contents of a cell to the specified file.

About This Article

This article is from the book:

About the book author:

John Paul Mueller is a freelance author and technical editor with more than 107 books and 600 articles to his credit. His subjects range from networking and artificial intelligence to database management and heads-down programming. He also consults and writes certification exams. Visit his website at

This article can be found in the category: