IPython Documentation

Table Of Contents

Previous topic


Next topic


This Page


Module: core.magics

Inheritance diagram for IPython.core.magics:

Implementation of all the magic functions built into IPython.


class IPython.core.magics.UserMagics(shell)

Bases: IPython.core.magic.Magics

Placeholder for user-defined magics to be added at runtime.

All magics are eventually merged into a single namespace at runtime, but we use this class to isolate the magics defined dynamically by the user into their own class.


Print docstring if incorrect arguments were passed

default_option(fn, optstr)

Make an entry in the options_table for fn, with value optstr


Format a string for latex inclusion.

magics = {'cell': {}, 'line': {}}
options_table = None
parse_options(arg_str, opt_str, *long_opts, **kw)

Parse options passed to an argument string.

The interface is similar to that of getopt(), but it returns back a Struct with the options as keys and the stripped argument string still as a string.

arg_str is quoted as a true sys.argv vector by using shlex.split. This allows us to easily expand variables, glob files, quote arguments, etc.


-mode: default ‘string’. If given as ‘list’, the argument string is returned as a list (split on whitespace) instead of a string.

-list_all: put all option values in lists. Normally only options appearing more than once are put in a list.

-posix (True): whether to split the input line in POSIX mode or not, as per the conventions outlined in the shlex module from the standard library.

registered = True
shell = None