Module: core.magics.config
Implementation of configuration-related magic functions.
1 Class
- class IPython.core.magics.config.ConfigMagics(**kwargs: Any)
Bases:
Magics- __init__(shell)
Create a configurable given a config config.
- Parameters:
config (Config) – If this is empty, default values are used. If config is a
Configinstance, 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 ofConfigurablebefore doing anything else and usingsuper():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.
- 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
valuewill 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: AliasManager DisplayFormatter HistoryManager IPCompleter LoggingMagics MagicsManager OSMagics PrefilterManager ScriptMagics TerminalInteractiveShell
To view what is configurable on a given class, just pass the class name:
In [2]: %config LoggingMagics LoggingMagics(Magics) options --------------------------- LoggingMagics.quiet=<Bool> Suppress output of log state when logging is enabled Current: False
but the real use is in setting values:
In [3]: %config LoggingMagics.quiet = True
and these values are read from the user_ns if they are variables:
In [4]: feeling_quiet=False In [5]: %config LoggingMagics.quiet = feeling_quiet