IPython Documentation

Table Of Contents

Previous topic

core.magics.code

Next topic

core.magics.deprecated

This Page

core.magics.config

Module: core.magics.config

Inheritance diagram for IPython.core.magics.config:

Implementation of configuration-related magic functions.

ConfigMagics

class IPython.core.magics.config.ConfigMagics(shell)

Bases: IPython.core.magic.Magics

__init__(shell)
arg_err(func)

Print docstring if incorrect arguments were passed

config(s)

configure IPython

%config Class[.trait=value]

This magic exposes most of the IPython config system. Any Configurable class should be able to be configured with the simple line:

%config Class.trait=value

Where value will be resolved in the user’s namespace, if it is an expression or variable name.

Examples

To see what classes are available for config, pass no arguments:

In [1]: %config
Available objects for config:
    TerminalInteractiveShell
    HistoryManager
    PrefilterManager
    AliasManager
    IPCompleter
    PromptManager
    DisplayFormatter

To view what is configurable on a given class, just pass the class name:

In [2]: %config IPCompleter
IPCompleter options
-----------------
IPCompleter.omit__names=<Enum>
    Current: 2
    Choices: (0, 1, 2)
    Instruct the completer to omit private method names
    Specifically, when completing on ``object.<tab>``.
    When 2 [default]: all names that start with '_' will be excluded.
    When 1: all 'magic' names (``__foo__``) will be excluded.
    When 0: nothing will be excluded.
IPCompleter.merge_completions=<CBool>
    Current: True
    Whether to merge completion results into a single list
    If False, only the completion results from the first non-empty
    completer will be returned.
IPCompleter.limit_to__all__=<CBool>
    Current: False
    Instruct the completer to use __all__ for the completion
    Specifically, when completing on ``object.<tab>``.
    When True: only those names in obj.__all__ will be included.
    When False [default]: the __all__ attribute is ignored
IPCompleter.greedy=<CBool>
    Current: False
    Activate greedy completion
    This will enable completion on elements of lists, results of
    function calls, etc., but can be unsafe because the code is
    actually evaluated on TAB.

but the real use is in setting values:

In [3]: %config IPCompleter.greedy = True

and these values are read from the user_ns if they are variables:

In [4]: feeling_greedy=False

In [5]: %config IPCompleter.greedy = feeling_greedy
default_option(fn, optstr)

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

format_latex(strng)

Format a string for latex inclusion.

magics = {'cell': {}, 'line': {'config': 'config'}}
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.

Options:

-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