Module:core.magics.config
Implementation of configuration-related magic functions.
1 Class
- classIPython.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 theinstance.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():classMyConfigurable(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. AnyConfigurable class should be able to be configured with the simpleline:
%configClass.trait=value
Where
valuewill be resolved in the user’s namespace, if it is anexpression or variable name.Examples
To see what classes are available for config, pass no arguments:
In[1]:%configAvailableobjectsforconfig:AliasManagerDisplayFormatterHistoryManagerIPCompleterLoggingMagicsMagicsManagerOSMagicsPrefilterManagerScriptMagicsTerminalInteractiveShell
To view what is configurable on a given class, just pass the classname:
In[2]:%configLoggingMagicsLoggingMagics(Magics)options---------------------------LoggingMagics.quiet=<Bool>SuppressoutputoflogstatewhenloggingisenabledCurrent:False
but the real use is in setting values:
In[3]:%configLoggingMagics.quiet=True
and these values are read from the user_ns if they are variables:
In[4]:feeling_quiet=FalseIn[5]:%configLoggingMagics.quiet=feeling_quiet