Warning

This documentation covers a development version of IPython. The development version may differ significantly from the latest stable release.

Important

This documentation covers IPython versions 6.0 and higher. Beginning with version 6.0, IPython stopped supporting compatibility with Python versions lower than 3.3 including all versions of Python 2.7.

If you are looking for an IPython version compatible with Python 2.7, please use the IPython 5.x LTS release and refer to its documentation (LTS is the long term support release).

Module: core.magics.auto

Implementation of magic functions that control various automatic behaviors.

1 Class

class IPython.core.magics.auto.AutoMagics(**kwargs: Any)

Bases: Magics

Magics that control various autoX behaviors.

__init__(shell)

Create a configurable given a config config.

Parameters:
  • config (Config) – If this is empty, default values are used. If config is a Config instance, it will be used to configure the instance.

  • parent (Configurable instance, optional) – The parent Configurable instance of this object.

Notes

Subclasses of Configurable must call the __init__() method of Configurable before doing anything else and using super():

class MyConfigurable(Configurable):
    def __init__(self, config=None):
        super(MyConfigurable, self).__init__(config=config)
        # Then any other code you need to finish initialization.

This ensures that instances will be configured properly.

autocall(parameter_s='')

Make functions callable without having to type parentheses.

Usage:

%autocall [mode]

The mode can be one of: 0->Off, 1->Smart, 2->Full. If not given, the value is toggled on and off (remembering the previous state).

In more detail, these values mean:

0 -> fully disabled

1 -> active, but do not apply if there are no arguments on the line.

In this mode, you get:

In [1]: callable
Out[1]: <built-in function callable>

In [2]: callable 'hello'
------> callable('hello')
Out[2]: False

2 -> Active always. Even if no arguments are present, the callable object is called:

In [2]: float
------> float()
Out[2]: 0.0

Note that even with autocall off, you can still use ‘/’ at the start of a line to treat the first argument on the command line as a function and add parentheses to it:

In [8]: /str 43
------> str(43)
Out[8]: '43'

# all-random (note for auto-testing)

automagic(parameter_s='')

Make magic functions callable without having to type the initial %.

Without arguments toggles on/off (when off, you must call it as %automagic, of course). With arguments it sets the value, and you can use any of (case insensitive):

  • on, 1, True: to activate

  • off, 0, False: to deactivate.

Note that magic functions have lowest priority, so if there’s a variable whose name collides with that of a magic fn, automagic won’t work for that function (you get the variable instead). However, if you delete the variable (del var), the previously shadowed magic function becomes visible to automagic again.