##// END OF EJS Templates
Update config docs.
Thomas Kluyver -
Show More
@@ -1,147 +1,137 b''
1 .. _configuring_ipython:
1 .. _configuring_ipython:
2
2
3 ===========================================================
3 ===========================================================
4 Configuring the :command:`ipython` command line application
4 Configuring the :command:`ipython` command line application
5 ===========================================================
5 ===========================================================
6
6
7 This section contains information about how to configure the
7 This section contains information about how to configure the
8 :command:`ipython` command line application. See the :ref:`configuration
8 :command:`ipython` command line application. See the :ref:`configuration
9 overview <config_overview>` for a more general description of the
9 overview <config_overview>` for a more general description of the
10 configuration system and configuration file format.
10 configuration system and configuration file format.
11
11
12 The default configuration file for the :command:`ipython` command line application
12 The default configuration file for the :command:`ipython` command line application
13 is :file:`ipython_config.py`. By setting the attributes in this file, you
13 is :file:`profile_default/ipython_config.py` in your :ref:`IPython directory
14 can configure the application. A sample is provided in
14 <ipython_dir>`. By setting the attributes in this file, you can configure the
15 :mod:`IPython.config.default.ipython_config`. Simply copy this file to your
15 application. To create the default config file, run this command::
16 :ref:`IPython directory <ipython_dir>` to start using it.
16
17 $ ipython profile create
17
18
18 Most configuration attributes that this file accepts are associated with classes
19 Most configuration attributes that this file accepts are associated with classes
19 that are subclasses of :class:`~IPython.config.configurable.Configurable`.
20 that are subclasses of :class:`~IPython.config.configurable.Configurable`.
20
21
21 Applications themselves are Configurable as well, so we will start with some
22 Applications themselves are Configurable as well, so we will start with some
22 application-level config.
23 application-level config.
23
24
24 Application-level configuration
25 Application-level configuration
25 ===============================
26 ===============================
26
27
27 Assuming that your configuration file has the following at the top::
28 Assuming that your configuration file has the following at the top::
28
29
29 c = get_config()
30 c = get_config()
30
31
31 the following attributes are set application-wide:
32 the following attributes are set application-wide:
32
33
33 terminal IPython-only flags:
34 terminal IPython-only flags:
34
35
35 :attr:`c.TerminalIPythonApp.display_banner`
36 :attr:`c.TerminalIPythonApp.display_banner`
36 A boolean that determined if the banner is printer when :command:`ipython`
37 A boolean that determined if the banner is printer when :command:`ipython`
37 is started.
38 is started.
38
39
39 :attr:`c.TerminalIPythonApp.classic`
40 :attr:`c.TerminalIPythonApp.classic`
40 A boolean that determines if IPython starts in "classic" mode. In this
41 A boolean that determines if IPython starts in "classic" mode. In this
41 mode, the prompts and everything mimic that of the normal :command:`python`
42 mode, the prompts and everything mimic that of the normal :command:`python`
42 shell
43 shell
43
44
44 :attr:`c.TerminalIPythonApp.nosep`
45 :attr:`c.TerminalIPythonApp.nosep`
45 A boolean that determines if there should be no blank lines between
46 A boolean that determines if there should be no blank lines between
46 prompts.
47 prompts.
47
48
48 :attr:`c.Application.log_level`
49 :attr:`c.Application.log_level`
49 An integer that sets the detail of the logging level during the startup
50 An integer that sets the detail of the logging level during the startup
50 of :command:`ipython`. The default is 30 and the possible values are
51 of :command:`ipython`. The default is 30 and the possible values are
51 (0, 10, 20, 30, 40, 50). Higher is quieter and lower is more verbose.
52 (0, 10, 20, 30, 40, 50). Higher is quieter and lower is more verbose.
52 This can also be set by the name of the logging level, e.g. INFO=20,
53 This can also be set by the name of the logging level, e.g. INFO=20,
53 WARN=30.
54 WARN=30.
54
55
55 Some options, such as extensions and startup code, can be set for any
56 Some options, such as extensions and startup code, can be set for any
56 application that starts an
57 application that starts an
57 :class:`~IPython.core.interactiveshell.InteractiveShell`. These apps are
58 :class:`~IPython.core.interactiveshell.InteractiveShell`. These apps are
58 subclasses of :class:`~IPython.core.shellapp.InteractiveShellApp`. Since
59 subclasses of :class:`~IPython.core.shellapp.InteractiveShellApp`. Since
59 subclasses inherit configuration, setting a trait of
60 subclasses inherit configuration, setting a trait of
60 :attr:`c.InteractiveShellApp` will affect all IPython applications, but if you
61 :attr:`c.InteractiveShellApp` will affect all IPython applications, but if you
61 want terminal IPython and the QtConsole to have different values, you can set
62 want terminal IPython and the QtConsole to have different values, you can set
62 them via :attr:`c.TerminalIPythonApp` and :attr:`c.IPKernelApp` respectively.
63 them via :attr:`c.TerminalIPythonApp` and :attr:`c.IPKernelApp` respectively.
63
64
64
65
65 :attr:`c.InteractiveShellApp.extensions`
66 :attr:`c.InteractiveShellApp.extensions`
66 A list of strings, each of which is an importable IPython extension. An
67 A list of strings, each of which is an importable IPython extension. See
67 IPython extension is a regular Python module or package that has a
68 :ref:`extensions_overview` for more details about extensions.
68 :func:`load_ipython_extension(ip)` method. This method gets called when
69 the extension is loaded with the currently running
70 :class:`~IPython.core.interactiveshell.InteractiveShell` as its only
71 argument. You can put your extensions anywhere they can be imported but we
72 add the :file:`extensions` subdirectory of the ipython directory to
73 ``sys.path`` during extension loading, so you can put them there as well.
74 Extensions are not executed in the user's interactive namespace and they
75 must be pure Python code. Extensions are the recommended way of customizing
76 :command:`ipython`. Extensions can provide an
77 :func:`unload_ipython_extension` that will be called when the extension is
78 unloaded.
79
69
80 :attr:`c.InteractiveShellApp.exec_lines`
70 :attr:`c.InteractiveShellApp.exec_lines`
81 A list of strings, each of which is Python code that is run in the user's
71 A list of strings, each of which is Python code that is run in the user's
82 namespace after IPython start. These lines can contain full IPython syntax
72 namespace after IPython start. These lines can contain full IPython syntax
83 with magics, etc.
73 with magics, etc.
84
74
85 :attr:`c.InteractiveShellApp.exec_files`
75 :attr:`c.InteractiveShellApp.exec_files`
86 A list of strings, each of which is the full pathname of a ``.py`` or
76 A list of strings, each of which is the full pathname of a ``.py`` or
87 ``.ipy`` file that will be executed as IPython starts. These files are run
77 ``.ipy`` file that will be executed as IPython starts. These files are run
88 in IPython in the user's namespace. Files with a ``.py`` extension need to
78 in IPython in the user's namespace. Files with a ``.py`` extension need to
89 be pure Python. Files with a ``.ipy`` extension can have custom IPython
79 be pure Python. Files with a ``.ipy`` extension can have custom IPython
90 syntax (magics, etc.). These files need to be in the cwd, the ipythondir
80 syntax (magics, etc.). These files need to be in the cwd, the ipythondir
91 or be absolute paths.
81 or be absolute paths.
92
82
93 Classes that can be configured
83 Classes that can be configured
94 ==============================
84 ==============================
95
85
96 The following classes can also be configured in the configuration file for
86 The following classes can also be configured in the configuration file for
97 :command:`ipython`:
87 :command:`ipython`:
98
88
99 * :class:`~IPython.core.interactiveshell.InteractiveShell`
89 * :class:`~IPython.core.interactiveshell.InteractiveShell`
100
90
101 * :class:`~IPython.core.prefilter.PrefilterManager`
91 * :class:`~IPython.core.prefilter.PrefilterManager`
102
92
103 * :class:`~IPython.core.alias.AliasManager`
93 * :class:`~IPython.core.alias.AliasManager`
104
94
105 To see which attributes of these classes are configurable, please see the
95 To see which attributes of these classes are configurable, please see the
106 source code for these classes, the class docstrings or the sample
96 source code for these classes, the class docstrings or the sample
107 configuration file :mod:`IPython.config.default.ipython_config`.
97 configuration file :mod:`IPython.config.default.ipython_config`.
108
98
109 Example
99 Example
110 =======
100 =======
111
101
112 For those who want to get a quick start, here is a sample
102 For those who want to get a quick start, here is a sample
113 :file:`ipython_config.py` that sets some of the common configuration
103 :file:`ipython_config.py` that sets some of the common configuration
114 attributes::
104 attributes::
115
105
116 # sample ipython_config.py
106 # sample ipython_config.py
117 c = get_config()
107 c = get_config()
118
108
119 c.IPythonTerminalApp.display_banner = True
109 c.TerminalIPythonApp.display_banner = True
120 c.InteractiveShellApp.log_level = 20
110 c.InteractiveShellApp.log_level = 20
121 c.InteractiveShellApp.extensions = [
111 c.InteractiveShellApp.extensions = [
122 'myextension'
112 'myextension'
123 ]
113 ]
124 c.InteractiveShellApp.exec_lines = [
114 c.InteractiveShellApp.exec_lines = [
125 'import numpy',
115 'import numpy',
126 'import scipy'
116 'import scipy'
127 ]
117 ]
128 c.InteractiveShellApp.exec_files = [
118 c.InteractiveShellApp.exec_files = [
129 'mycode.py',
119 'mycode.py',
130 'fancy.ipy'
120 'fancy.ipy'
131 ]
121 ]
132 c.InteractiveShell.autoindent = True
122 c.InteractiveShell.autoindent = True
133 c.InteractiveShell.colors = 'LightBG'
123 c.InteractiveShell.colors = 'LightBG'
134 c.InteractiveShell.confirm_exit = False
124 c.InteractiveShell.confirm_exit = False
135 c.InteractiveShell.deep_reload = True
125 c.InteractiveShell.deep_reload = True
136 c.InteractiveShell.editor = 'nano'
126 c.InteractiveShell.editor = 'nano'
137 c.InteractiveShell.prompt_in1 = 'In [\#]: '
127 c.InteractiveShell.prompt_in1 = 'In [\#]: '
138 c.InteractiveShell.prompt_in2 = ' .\D.: '
128 c.InteractiveShell.prompt_in2 = ' .\D.: '
139 c.InteractiveShell.prompt_out = 'Out[\#]: '
129 c.InteractiveShell.prompt_out = 'Out[\#]: '
140 c.InteractiveShell.prompts_pad_left = True
130 c.InteractiveShell.prompts_pad_left = True
141 c.InteractiveShell.xmode = 'Context'
131 c.InteractiveShell.xmode = 'Context'
142
132
143 c.PrefilterManager.multi_line_specials = True
133 c.PrefilterManager.multi_line_specials = True
144
134
145 c.AliasManager.user_aliases = [
135 c.AliasManager.user_aliases = [
146 ('la', 'ls -al')
136 ('la', 'ls -al')
147 ]
137 ]
@@ -1,528 +1,531 b''
1 .. _config_overview:
1 .. _config_overview:
2
2
3 ============================================
3 ============================================
4 Overview of the IPython configuration system
4 Overview of the IPython configuration system
5 ============================================
5 ============================================
6
6
7 This section describes the IPython configuration system. Starting with version
7 This section describes the IPython configuration system. Starting with version
8 0.11, IPython has a completely new configuration system that is quite
8 0.11, IPython has a completely new configuration system that is quite
9 different from the older :file:`ipythonrc` or :file:`ipy_user_conf.py`
9 different from the older :file:`ipythonrc` or :file:`ipy_user_conf.py`
10 approaches. The new configuration system was designed from scratch to address
10 approaches. The new configuration system was designed from scratch to address
11 the particular configuration needs of IPython. While there are many
11 the particular configuration needs of IPython. While there are many
12 other excellent configuration systems out there, we found that none of them
12 other excellent configuration systems out there, we found that none of them
13 met our requirements.
13 met our requirements.
14
14
15 .. warning::
15 .. warning::
16
16
17 If you are upgrading to version 0.11 of IPython, you will need to migrate
17 If you are upgrading to version 0.11 of IPython, you will need to migrate
18 your old :file:`ipythonrc` or :file:`ipy_user_conf.py` configuration files
18 your old :file:`ipythonrc` or :file:`ipy_user_conf.py` configuration files
19 to the new system. Read on for information on how to do this.
19 to the new system. You may want to read the section on
20 :ref:`configuring IPython <configuring_ipython>`. There are also some ideas
21 `on the IPython wiki <http://wiki.ipython.org/Cookbook/Moving_config_to_IPython_0.11>`_
22 about this.
20
23
21 The discussion that follows is focused on teaching users how to configure
24 The discussion that follows is focused on teaching users how to configure
22 IPython to their liking. Developers who want to know more about how they
25 IPython to their liking. Developers who want to know more about how they
23 can enable their objects to take advantage of the configuration system
26 can enable their objects to take advantage of the configuration system
24 should consult our :ref:`developer guide <developer_guide>`
27 should consult our :ref:`developer guide <developer_guide>`
25
28
26 The main concepts
29 The main concepts
27 =================
30 =================
28
31
29 There are a number of abstractions that the IPython configuration system uses.
32 There are a number of abstractions that the IPython configuration system uses.
30 Each of these abstractions is represented by a Python class.
33 Each of these abstractions is represented by a Python class.
31
34
32 Configuration object: :class:`~IPython.config.loader.Config`
35 Configuration object: :class:`~IPython.config.loader.Config`
33 A configuration object is a simple dictionary-like class that holds
36 A configuration object is a simple dictionary-like class that holds
34 configuration attributes and sub-configuration objects. These classes
37 configuration attributes and sub-configuration objects. These classes
35 support dotted attribute style access (``Foo.bar``) in addition to the
38 support dotted attribute style access (``Foo.bar``) in addition to the
36 regular dictionary style access (``Foo['bar']``). Configuration objects
39 regular dictionary style access (``Foo['bar']``). Configuration objects
37 are smart. They know how to merge themselves with other configuration
40 are smart. They know how to merge themselves with other configuration
38 objects and they automatically create sub-configuration objects.
41 objects and they automatically create sub-configuration objects.
39
42
40 Application: :class:`~IPython.config.application.Application`
43 Application: :class:`~IPython.config.application.Application`
41 An application is a process that does a specific job. The most obvious
44 An application is a process that does a specific job. The most obvious
42 application is the :command:`ipython` command line program. Each
45 application is the :command:`ipython` command line program. Each
43 application reads *one or more* configuration files and a single set of
46 application reads *one or more* configuration files and a single set of
44 command line options
47 command line options
45 and then produces a master configuration object for the application. This
48 and then produces a master configuration object for the application. This
46 configuration object is then passed to the configurable objects that the
49 configuration object is then passed to the configurable objects that the
47 application creates. These configurable objects implement the actual logic
50 application creates. These configurable objects implement the actual logic
48 of the application and know how to configure themselves given the
51 of the application and know how to configure themselves given the
49 configuration object.
52 configuration object.
50
53
51 Applications always have a `log` attribute that is a configured Logger.
54 Applications always have a `log` attribute that is a configured Logger.
52 This allows centralized logging configuration per-application.
55 This allows centralized logging configuration per-application.
53
56
54 Configurable: :class:`~IPython.config.configurable.Configurable`
57 Configurable: :class:`~IPython.config.configurable.Configurable`
55 A configurable is a regular Python class that serves as a base class for
58 A configurable is a regular Python class that serves as a base class for
56 all main classes in an application. The
59 all main classes in an application. The
57 :class:`~IPython.config.configurable.Configurable` base class is
60 :class:`~IPython.config.configurable.Configurable` base class is
58 lightweight and only does one things.
61 lightweight and only does one things.
59
62
60 This :class:`~IPython.config.configurable.Configurable` is a subclass
63 This :class:`~IPython.config.configurable.Configurable` is a subclass
61 of :class:`~IPython.utils.traitlets.HasTraits` that knows how to configure
64 of :class:`~IPython.utils.traitlets.HasTraits` that knows how to configure
62 itself. Class level traits with the metadata ``config=True`` become
65 itself. Class level traits with the metadata ``config=True`` become
63 values that can be configured from the command line and configuration
66 values that can be configured from the command line and configuration
64 files.
67 files.
65
68
66 Developers create :class:`~IPython.config.configurable.Configurable`
69 Developers create :class:`~IPython.config.configurable.Configurable`
67 subclasses that implement all of the logic in the application. Each of
70 subclasses that implement all of the logic in the application. Each of
68 these subclasses has its own configuration information that controls how
71 these subclasses has its own configuration information that controls how
69 instances are created.
72 instances are created.
70
73
71 Singletons: :class:`~IPython.config.configurable.SingletonConfigurable`
74 Singletons: :class:`~IPython.config.configurable.SingletonConfigurable`
72 Any object for which there is a single canonical instance. These are
75 Any object for which there is a single canonical instance. These are
73 just like Configurables, except they have a class method
76 just like Configurables, except they have a class method
74 :meth:`~IPython.config.configurable.SingletonConfigurable.instance`,
77 :meth:`~IPython.config.configurable.SingletonConfigurable.instance`,
75 that returns the current active instance (or creates one if it
78 that returns the current active instance (or creates one if it
76 does not exist). Examples of singletons include
79 does not exist). Examples of singletons include
77 :class:`~IPython.config.application.Application`s and
80 :class:`~IPython.config.application.Application`s and
78 :class:`~IPython.core.interactiveshell.InteractiveShell`. This lets
81 :class:`~IPython.core.interactiveshell.InteractiveShell`. This lets
79 objects easily connect to the current running Application without passing
82 objects easily connect to the current running Application without passing
80 objects around everywhere. For instance, to get the current running
83 objects around everywhere. For instance, to get the current running
81 Application instance, simply do: ``app = Application.instance()``.
84 Application instance, simply do: ``app = Application.instance()``.
82
85
83
86
84 .. note::
87 .. note::
85
88
86 Singletons are not strictly enforced - you can have many instances
89 Singletons are not strictly enforced - you can have many instances
87 of a given singleton class, but the :meth:`instance` method will always
90 of a given singleton class, but the :meth:`instance` method will always
88 return the same one.
91 return the same one.
89
92
90 Having described these main concepts, we can now state the main idea in our
93 Having described these main concepts, we can now state the main idea in our
91 configuration system: *"configuration" allows the default values of class
94 configuration system: *"configuration" allows the default values of class
92 attributes to be controlled on a class by class basis*. Thus all instances of
95 attributes to be controlled on a class by class basis*. Thus all instances of
93 a given class are configured in the same way. Furthermore, if two instances
96 a given class are configured in the same way. Furthermore, if two instances
94 need to be configured differently, they need to be instances of two different
97 need to be configured differently, they need to be instances of two different
95 classes. While this model may seem a bit restrictive, we have found that it
98 classes. While this model may seem a bit restrictive, we have found that it
96 expresses most things that need to be configured extremely well. However, it
99 expresses most things that need to be configured extremely well. However, it
97 is possible to create two instances of the same class that have different
100 is possible to create two instances of the same class that have different
98 trait values. This is done by overriding the configuration.
101 trait values. This is done by overriding the configuration.
99
102
100 Now, we show what our configuration objects and files look like.
103 Now, we show what our configuration objects and files look like.
101
104
102 Configuration objects and files
105 Configuration objects and files
103 ===============================
106 ===============================
104
107
105 A configuration file is simply a pure Python file that sets the attributes
108 A configuration file is simply a pure Python file that sets the attributes
106 of a global, pre-created configuration object. This configuration object is a
109 of a global, pre-created configuration object. This configuration object is a
107 :class:`~IPython.config.loader.Config` instance. While in a configuration
110 :class:`~IPython.config.loader.Config` instance. While in a configuration
108 file, to get a reference to this object, simply call the :func:`get_config`
111 file, to get a reference to this object, simply call the :func:`get_config`
109 function. We inject this function into the global namespace that the
112 function. We inject this function into the global namespace that the
110 configuration file is executed in.
113 configuration file is executed in.
111
114
112 Here is an example of a super simple configuration file that does nothing::
115 Here is an example of a super simple configuration file that does nothing::
113
116
114 c = get_config()
117 c = get_config()
115
118
116 Once you get a reference to the configuration object, you simply set
119 Once you get a reference to the configuration object, you simply set
117 attributes on it. All you have to know is:
120 attributes on it. All you have to know is:
118
121
119 * The name of each attribute.
122 * The name of each attribute.
120 * The type of each attribute.
123 * The type of each attribute.
121
124
122 The answers to these two questions are provided by the various
125 The answers to these two questions are provided by the various
123 :class:`~IPython.config.configurable.Configurable` subclasses that an
126 :class:`~IPython.config.configurable.Configurable` subclasses that an
124 application uses. Let's look at how this would work for a simple configurable
127 application uses. Let's look at how this would work for a simple configurable
125 subclass::
128 subclass::
126
129
127 # Sample configurable:
130 # Sample configurable:
128 from IPython.config.configurable import Configurable
131 from IPython.config.configurable import Configurable
129 from IPython.utils.traitlets import Int, Float, Unicode, Bool
132 from IPython.utils.traitlets import Int, Float, Unicode, Bool
130
133
131 class MyClass(Configurable):
134 class MyClass(Configurable):
132 name = Unicode(u'defaultname', config=True)
135 name = Unicode(u'defaultname', config=True)
133 ranking = Int(0, config=True)
136 ranking = Int(0, config=True)
134 value = Float(99.0)
137 value = Float(99.0)
135 # The rest of the class implementation would go here..
138 # The rest of the class implementation would go here..
136
139
137 In this example, we see that :class:`MyClass` has three attributes, two
140 In this example, we see that :class:`MyClass` has three attributes, two
138 of whom (``name``, ``ranking``) can be configured. All of the attributes
141 of whom (``name``, ``ranking``) can be configured. All of the attributes
139 are given types and default values. If a :class:`MyClass` is instantiated,
142 are given types and default values. If a :class:`MyClass` is instantiated,
140 but not configured, these default values will be used. But let's see how
143 but not configured, these default values will be used. But let's see how
141 to configure this class in a configuration file::
144 to configure this class in a configuration file::
142
145
143 # Sample config file
146 # Sample config file
144 c = get_config()
147 c = get_config()
145
148
146 c.MyClass.name = 'coolname'
149 c.MyClass.name = 'coolname'
147 c.MyClass.ranking = 10
150 c.MyClass.ranking = 10
148
151
149 After this configuration file is loaded, the values set in it will override
152 After this configuration file is loaded, the values set in it will override
150 the class defaults anytime a :class:`MyClass` is created. Furthermore,
153 the class defaults anytime a :class:`MyClass` is created. Furthermore,
151 these attributes will be type checked and validated anytime they are set.
154 these attributes will be type checked and validated anytime they are set.
152 This type checking is handled by the :mod:`IPython.utils.traitlets` module,
155 This type checking is handled by the :mod:`IPython.utils.traitlets` module,
153 which provides the :class:`Unicode`, :class:`Int` and :class:`Float` types.
156 which provides the :class:`Unicode`, :class:`Int` and :class:`Float` types.
154 In addition to these traitlets, the :mod:`IPython.utils.traitlets` provides
157 In addition to these traitlets, the :mod:`IPython.utils.traitlets` provides
155 traitlets for a number of other types.
158 traitlets for a number of other types.
156
159
157 .. note::
160 .. note::
158
161
159 Underneath the hood, the :class:`Configurable` base class is a subclass of
162 Underneath the hood, the :class:`Configurable` base class is a subclass of
160 :class:`IPython.utils.traitlets.HasTraits`. The
163 :class:`IPython.utils.traitlets.HasTraits`. The
161 :mod:`IPython.utils.traitlets` module is a lightweight version of
164 :mod:`IPython.utils.traitlets` module is a lightweight version of
162 :mod:`enthought.traits`. Our implementation is a pure Python subset
165 :mod:`enthought.traits`. Our implementation is a pure Python subset
163 (mostly API compatible) of :mod:`enthought.traits` that does not have any
166 (mostly API compatible) of :mod:`enthought.traits` that does not have any
164 of the automatic GUI generation capabilities. Our plan is to achieve 100%
167 of the automatic GUI generation capabilities. Our plan is to achieve 100%
165 API compatibility to enable the actual :mod:`enthought.traits` to
168 API compatibility to enable the actual :mod:`enthought.traits` to
166 eventually be used instead. Currently, we cannot use
169 eventually be used instead. Currently, we cannot use
167 :mod:`enthought.traits` as we are committed to the core of IPython being
170 :mod:`enthought.traits` as we are committed to the core of IPython being
168 pure Python.
171 pure Python.
169
172
170 It should be very clear at this point what the naming convention is for
173 It should be very clear at this point what the naming convention is for
171 configuration attributes::
174 configuration attributes::
172
175
173 c.ClassName.attribute_name = attribute_value
176 c.ClassName.attribute_name = attribute_value
174
177
175 Here, ``ClassName`` is the name of the class whose configuration attribute you
178 Here, ``ClassName`` is the name of the class whose configuration attribute you
176 want to set, ``attribute_name`` is the name of the attribute you want to set
179 want to set, ``attribute_name`` is the name of the attribute you want to set
177 and ``attribute_value`` the the value you want it to have. The ``ClassName``
180 and ``attribute_value`` the the value you want it to have. The ``ClassName``
178 attribute of ``c`` is not the actual class, but instead is another
181 attribute of ``c`` is not the actual class, but instead is another
179 :class:`~IPython.config.loader.Config` instance.
182 :class:`~IPython.config.loader.Config` instance.
180
183
181 .. note::
184 .. note::
182
185
183 The careful reader may wonder how the ``ClassName`` (``MyClass`` in
186 The careful reader may wonder how the ``ClassName`` (``MyClass`` in
184 the above example) attribute of the configuration object ``c`` gets
187 the above example) attribute of the configuration object ``c`` gets
185 created. These attributes are created on the fly by the
188 created. These attributes are created on the fly by the
186 :class:`~IPython.config.loader.Config` instance, using a simple naming
189 :class:`~IPython.config.loader.Config` instance, using a simple naming
187 convention. Any attribute of a :class:`~IPython.config.loader.Config`
190 convention. Any attribute of a :class:`~IPython.config.loader.Config`
188 instance whose name begins with an uppercase character is assumed to be a
191 instance whose name begins with an uppercase character is assumed to be a
189 sub-configuration and a new empty :class:`~IPython.config.loader.Config`
192 sub-configuration and a new empty :class:`~IPython.config.loader.Config`
190 instance is dynamically created for that attribute. This allows deeply
193 instance is dynamically created for that attribute. This allows deeply
191 hierarchical information created easily (``c.Foo.Bar.value``) on the fly.
194 hierarchical information created easily (``c.Foo.Bar.value``) on the fly.
192
195
193 Configuration files inheritance
196 Configuration files inheritance
194 ===============================
197 ===============================
195
198
196 Let's say you want to have different configuration files for various purposes.
199 Let's say you want to have different configuration files for various purposes.
197 Our configuration system makes it easy for one configuration file to inherit
200 Our configuration system makes it easy for one configuration file to inherit
198 the information in another configuration file. The :func:`load_subconfig`
201 the information in another configuration file. The :func:`load_subconfig`
199 command can be used in a configuration file for this purpose. Here is a simple
202 command can be used in a configuration file for this purpose. Here is a simple
200 example that loads all of the values from the file :file:`base_config.py`::
203 example that loads all of the values from the file :file:`base_config.py`::
201
204
202 # base_config.py
205 # base_config.py
203 c = get_config()
206 c = get_config()
204 c.MyClass.name = 'coolname'
207 c.MyClass.name = 'coolname'
205 c.MyClass.ranking = 100
208 c.MyClass.ranking = 100
206
209
207 into the configuration file :file:`main_config.py`::
210 into the configuration file :file:`main_config.py`::
208
211
209 # main_config.py
212 # main_config.py
210 c = get_config()
213 c = get_config()
211
214
212 # Load everything from base_config.py
215 # Load everything from base_config.py
213 load_subconfig('base_config.py')
216 load_subconfig('base_config.py')
214
217
215 # Now override one of the values
218 # Now override one of the values
216 c.MyClass.name = 'bettername'
219 c.MyClass.name = 'bettername'
217
220
218 In a situation like this the :func:`load_subconfig` makes sure that the
221 In a situation like this the :func:`load_subconfig` makes sure that the
219 search path for sub-configuration files is inherited from that of the parent.
222 search path for sub-configuration files is inherited from that of the parent.
220 Thus, you can typically put the two in the same directory and everything will
223 Thus, you can typically put the two in the same directory and everything will
221 just work.
224 just work.
222
225
223 You can also load configuration files by profile, for instance:
226 You can also load configuration files by profile, for instance:
224
227
225 .. sourcecode:: python
228 .. sourcecode:: python
226
229
227 load_subconfig('ipython_config.py', profile='default')
230 load_subconfig('ipython_config.py', profile='default')
228
231
229 to inherit your default configuration as a starting point.
232 to inherit your default configuration as a starting point.
230
233
231
234
232 Class based configuration inheritance
235 Class based configuration inheritance
233 =====================================
236 =====================================
234
237
235 There is another aspect of configuration where inheritance comes into play.
238 There is another aspect of configuration where inheritance comes into play.
236 Sometimes, your classes will have an inheritance hierarchy that you want
239 Sometimes, your classes will have an inheritance hierarchy that you want
237 to be reflected in the configuration system. Here is a simple example::
240 to be reflected in the configuration system. Here is a simple example::
238
241
239 from IPython.config.configurable import Configurable
242 from IPython.config.configurable import Configurable
240 from IPython.utils.traitlets import Int, Float, Unicode, Bool
243 from IPython.utils.traitlets import Int, Float, Unicode, Bool
241
244
242 class Foo(Configurable):
245 class Foo(Configurable):
243 name = Unicode(u'fooname', config=True)
246 name = Unicode(u'fooname', config=True)
244 value = Float(100.0, config=True)
247 value = Float(100.0, config=True)
245
248
246 class Bar(Foo):
249 class Bar(Foo):
247 name = Unicode(u'barname', config=True)
250 name = Unicode(u'barname', config=True)
248 othervalue = Int(0, config=True)
251 othervalue = Int(0, config=True)
249
252
250 Now, we can create a configuration file to configure instances of :class:`Foo`
253 Now, we can create a configuration file to configure instances of :class:`Foo`
251 and :class:`Bar`::
254 and :class:`Bar`::
252
255
253 # config file
256 # config file
254 c = get_config()
257 c = get_config()
255
258
256 c.Foo.name = u'bestname'
259 c.Foo.name = u'bestname'
257 c.Bar.othervalue = 10
260 c.Bar.othervalue = 10
258
261
259 This class hierarchy and configuration file accomplishes the following:
262 This class hierarchy and configuration file accomplishes the following:
260
263
261 * The default value for :attr:`Foo.name` and :attr:`Bar.name` will be
264 * The default value for :attr:`Foo.name` and :attr:`Bar.name` will be
262 'bestname'. Because :class:`Bar` is a :class:`Foo` subclass it also
265 'bestname'. Because :class:`Bar` is a :class:`Foo` subclass it also
263 picks up the configuration information for :class:`Foo`.
266 picks up the configuration information for :class:`Foo`.
264 * The default value for :attr:`Foo.value` and :attr:`Bar.value` will be
267 * The default value for :attr:`Foo.value` and :attr:`Bar.value` will be
265 ``100.0``, which is the value specified as the class default.
268 ``100.0``, which is the value specified as the class default.
266 * The default value for :attr:`Bar.othervalue` will be 10 as set in the
269 * The default value for :attr:`Bar.othervalue` will be 10 as set in the
267 configuration file. Because :class:`Foo` is the parent of :class:`Bar`
270 configuration file. Because :class:`Foo` is the parent of :class:`Bar`
268 it doesn't know anything about the :attr:`othervalue` attribute.
271 it doesn't know anything about the :attr:`othervalue` attribute.
269
272
270
273
271 .. _ipython_dir:
274 .. _ipython_dir:
272
275
273 Configuration file location
276 Configuration file location
274 ===========================
277 ===========================
275
278
276 So where should you put your configuration files? IPython uses "profiles" for
279 So where should you put your configuration files? IPython uses "profiles" for
277 configuration, and by default, all profiles will be stored in the so called
280 configuration, and by default, all profiles will be stored in the so called
278 "IPython directory". The location of this directory is determined by the
281 "IPython directory". The location of this directory is determined by the
279 following algorithm:
282 following algorithm:
280
283
281 * If the ``ipython_dir`` command line flag is given, its value is used.
284 * If the ``ipython_dir`` command line flag is given, its value is used.
282
285
283 * If not, the value returned by :func:`IPython.utils.path.get_ipython_dir`
286 * If not, the value returned by :func:`IPython.utils.path.get_ipython_dir`
284 is used. This function will first look at the :envvar:`IPYTHON_DIR`
287 is used. This function will first look at the :envvar:`IPYTHON_DIR`
285 environment variable and then default to a platform-specific default.
288 environment variable and then default to a platform-specific default.
286
289
287 On posix systems (Linux, Unix, etc.), IPython respects the ``$XDG_CONFIG_HOME``
290 On posix systems (Linux, Unix, etc.), IPython respects the ``$XDG_CONFIG_HOME``
288 part of the `XDG Base Directory`_ specification. If ``$XDG_CONFIG_HOME`` is
291 part of the `XDG Base Directory`_ specification. If ``$XDG_CONFIG_HOME`` is
289 defined and exists ( ``XDG_CONFIG_HOME`` has a default interpretation of
292 defined and exists ( ``XDG_CONFIG_HOME`` has a default interpretation of
290 :file:`$HOME/.config`), then IPython's config directory will be located in
293 :file:`$HOME/.config`), then IPython's config directory will be located in
291 :file:`$XDG_CONFIG_HOME/ipython`. If users still have an IPython directory
294 :file:`$XDG_CONFIG_HOME/ipython`. If users still have an IPython directory
292 in :file:`$HOME/.ipython`, then that will be used. in preference to the
295 in :file:`$HOME/.ipython`, then that will be used. in preference to the
293 system default.
296 system default.
294
297
295 For most users, the default value will simply be something like
298 For most users, the default value will simply be something like
296 :file:`$HOME/.config/ipython` on Linux, or :file:`$HOME/.ipython`
299 :file:`$HOME/.config/ipython` on Linux, or :file:`$HOME/.ipython`
297 elsewhere.
300 elsewhere.
298
301
299 Once the location of the IPython directory has been determined, you need to know
302 Once the location of the IPython directory has been determined, you need to know
300 which profile you are using. For users with a single configuration, this will
303 which profile you are using. For users with a single configuration, this will
301 simply be 'default', and will be located in
304 simply be 'default', and will be located in
302 :file:`<IPYTHON_DIR>/profile_default`.
305 :file:`<IPYTHON_DIR>/profile_default`.
303
306
304 The next thing you need to know is what to call your configuration file. The
307 The next thing you need to know is what to call your configuration file. The
305 basic idea is that each application has its own default configuration filename.
308 basic idea is that each application has its own default configuration filename.
306 The default named used by the :command:`ipython` command line program is
309 The default named used by the :command:`ipython` command line program is
307 :file:`ipython_config.py`, and *all* IPython applications will use this file.
310 :file:`ipython_config.py`, and *all* IPython applications will use this file.
308 Other applications, such as the parallel :command:`ipcluster` scripts or the
311 Other applications, such as the parallel :command:`ipcluster` scripts or the
309 QtConsole will load their own config files *after* :file:`ipython_config.py`. To
312 QtConsole will load their own config files *after* :file:`ipython_config.py`. To
310 load a particular configuration file instead of the default, the name can be
313 load a particular configuration file instead of the default, the name can be
311 overridden by the ``config_file`` command line flag.
314 overridden by the ``config_file`` command line flag.
312
315
313 To generate the default configuration files, do::
316 To generate the default configuration files, do::
314
317
315 $> ipython profile create
318 $> ipython profile create
316
319
317 and you will have a default :file:`ipython_config.py` in your IPython directory
320 and you will have a default :file:`ipython_config.py` in your IPython directory
318 under :file:`profile_default`. If you want the default config files for the
321 under :file:`profile_default`. If you want the default config files for the
319 :mod:`IPython.parallel` applications, add ``--parallel`` to the end of the
322 :mod:`IPython.parallel` applications, add ``--parallel`` to the end of the
320 command-line args.
323 command-line args.
321
324
322 .. _Profiles:
325 .. _Profiles:
323
326
324 Profiles
327 Profiles
325 ========
328 ========
326
329
327 A profile is a directory containing configuration and runtime files, such as
330 A profile is a directory containing configuration and runtime files, such as
328 logs, connection info for the parallel apps, and your IPython command history.
331 logs, connection info for the parallel apps, and your IPython command history.
329
332
330 The idea is that users often want to maintain a set of configuration files for
333 The idea is that users often want to maintain a set of configuration files for
331 different purposes: one for doing numerical computing with NumPy and SciPy and
334 different purposes: one for doing numerical computing with NumPy and SciPy and
332 another for doing symbolic computing with SymPy. Profiles make it easy to keep a
335 another for doing symbolic computing with SymPy. Profiles make it easy to keep a
333 separate configuration files, logs, and histories for each of these purposes.
336 separate configuration files, logs, and histories for each of these purposes.
334
337
335 Let's start by showing how a profile is used:
338 Let's start by showing how a profile is used:
336
339
337 .. code-block:: bash
340 .. code-block:: bash
338
341
339 $ ipython --profile=sympy
342 $ ipython --profile=sympy
340
343
341 This tells the :command:`ipython` command line program to get its configuration
344 This tells the :command:`ipython` command line program to get its configuration
342 from the "sympy" profile. The file names for various profiles do not change. The
345 from the "sympy" profile. The file names for various profiles do not change. The
343 only difference is that profiles are named in a special way. In the case above,
346 only difference is that profiles are named in a special way. In the case above,
344 the "sympy" profile means looking for :file:`ipython_config.py` in :file:`<IPYTHON_DIR>/profile_sympy`.
347 the "sympy" profile means looking for :file:`ipython_config.py` in :file:`<IPYTHON_DIR>/profile_sympy`.
345
348
346 The general pattern is this: simply create a new profile with:
349 The general pattern is this: simply create a new profile with:
347
350
348 .. code-block:: bash
351 .. code-block:: bash
349
352
350 ipython profile create <name>
353 ipython profile create <name>
351
354
352 which adds a directory called ``profile_<name>`` to your IPython directory. Then
355 which adds a directory called ``profile_<name>`` to your IPython directory. Then
353 you can load this profile by adding ``--profile=<name>`` to your command line
356 you can load this profile by adding ``--profile=<name>`` to your command line
354 options. Profiles are supported by all IPython applications.
357 options. Profiles are supported by all IPython applications.
355
358
356 IPython ships with some sample profiles in :file:`IPython/config/profile`. If
359 IPython ships with some sample profiles in :file:`IPython/config/profile`. If
357 you create profiles with the name of one of our shipped profiles, these config
360 you create profiles with the name of one of our shipped profiles, these config
358 files will be copied over instead of starting with the automatically generated
361 files will be copied over instead of starting with the automatically generated
359 config files.
362 config files.
360
363
361 Security Files
364 Security Files
362 --------------
365 --------------
363
366
364 If you are using the notebook, qtconsole, or parallel code, IPython stores
367 If you are using the notebook, qtconsole, or parallel code, IPython stores
365 connection information in small JSON files in the active profile's security
368 connection information in small JSON files in the active profile's security
366 directory. This directory is made private, so only you can see the files inside. If
369 directory. This directory is made private, so only you can see the files inside. If
367 you need to move connection files around to other computers, this is where they will
370 you need to move connection files around to other computers, this is where they will
368 be. If you want your code to be able to open security files by name, we have a
371 be. If you want your code to be able to open security files by name, we have a
369 convenience function :func:`IPython.utils.path.get_security_file`, which will return
372 convenience function :func:`IPython.utils.path.get_security_file`, which will return
370 the absolute path to a security file from its filename and [optionally] profile
373 the absolute path to a security file from its filename and [optionally] profile
371 name.
374 name.
372
375
373 Startup Files
376 Startup Files
374 -------------
377 -------------
375
378
376 If you want some code to be run at the beginning of every IPython session with a
379 If you want some code to be run at the beginning of every IPython session with a
377 particular profile, the easiest way is to add Python (.py) or IPython (.ipy) scripts
380 particular profile, the easiest way is to add Python (.py) or IPython (.ipy) scripts
378 to your :file:`<profile>/startup` directory. Files in this directory will always be
381 to your :file:`<profile>/startup` directory. Files in this directory will always be
379 executed as soon as the IPython shell is constructed, and before any other code or
382 executed as soon as the IPython shell is constructed, and before any other code or
380 scripts you have specified. If you have multiple files in the startup directory,
383 scripts you have specified. If you have multiple files in the startup directory,
381 they will be run in lexicographical order, so you can control the ordering by adding
384 they will be run in lexicographical order, so you can control the ordering by adding
382 a '00-' prefix.
385 a '00-' prefix.
383
386
384 .. note::
387 .. note::
385
388
386 Automatic startup files are new in IPython 0.12. Use the
389 Automatic startup files are new in IPython 0.12. Use the
387 InteractiveShellApp.exec_files configurable for similar behavior in 0.11.
390 InteractiveShellApp.exec_files configurable for similar behavior in 0.11.
388
391
389
392
390 .. _commandline:
393 .. _commandline:
391
394
392 Command-line arguments
395 Command-line arguments
393 ======================
396 ======================
394
397
395 IPython exposes *all* configurable options on the command-line. The command-line
398 IPython exposes *all* configurable options on the command-line. The command-line
396 arguments are generated from the Configurable traits of the classes associated
399 arguments are generated from the Configurable traits of the classes associated
397 with a given Application. Configuring IPython from the command-line may look
400 with a given Application. Configuring IPython from the command-line may look
398 very similar to an IPython config file
401 very similar to an IPython config file
399
402
400 IPython applications use a parser called
403 IPython applications use a parser called
401 :class:`~IPython.config.loader.KeyValueLoader` to load values into a Config
404 :class:`~IPython.config.loader.KeyValueLoader` to load values into a Config
402 object. Values are assigned in much the same way as in a config file:
405 object. Values are assigned in much the same way as in a config file:
403
406
404 .. code-block:: bash
407 .. code-block:: bash
405
408
406 $> ipython --InteractiveShell.use_readline=False --BaseIPythonApplication.profile='myprofile'
409 $> ipython --InteractiveShell.use_readline=False --BaseIPythonApplication.profile='myprofile'
407
410
408 Is the same as adding:
411 Is the same as adding:
409
412
410 .. sourcecode:: python
413 .. sourcecode:: python
411
414
412 c.InteractiveShell.use_readline=False
415 c.InteractiveShell.use_readline=False
413 c.BaseIPythonApplication.profile='myprofile'
416 c.BaseIPythonApplication.profile='myprofile'
414
417
415 to your config file. Key/Value arguments *always* take a value, separated by '='
418 to your config file. Key/Value arguments *always* take a value, separated by '='
416 and no spaces.
419 and no spaces.
417
420
418 Common Arguments
421 Common Arguments
419 ****************
422 ****************
420
423
421 Since the strictness and verbosity of the KVLoader above are not ideal for everyday
424 Since the strictness and verbosity of the KVLoader above are not ideal for everyday
422 use, common arguments can be specified as flags_ or aliases_.
425 use, common arguments can be specified as flags_ or aliases_.
423
426
424 Flags and Aliases are handled by :mod:`argparse` instead, allowing for more flexible
427 Flags and Aliases are handled by :mod:`argparse` instead, allowing for more flexible
425 parsing. In general, flags and aliases are prefixed by ``--``, except for those
428 parsing. In general, flags and aliases are prefixed by ``--``, except for those
426 that are single characters, in which case they can be specified with a single ``-``, e.g.:
429 that are single characters, in which case they can be specified with a single ``-``, e.g.:
427
430
428 .. code-block:: bash
431 .. code-block:: bash
429
432
430 $> ipython -i -c "import numpy; x=numpy.linspace(0,1)" --profile testing --colors=lightbg
433 $> ipython -i -c "import numpy; x=numpy.linspace(0,1)" --profile testing --colors=lightbg
431
434
432 Aliases
435 Aliases
433 -------
436 -------
434
437
435 For convenience, applications have a mapping of commonly used traits, so you don't have
438 For convenience, applications have a mapping of commonly used traits, so you don't have
436 to specify the whole class name:
439 to specify the whole class name:
437
440
438 .. code-block:: bash
441 .. code-block:: bash
439
442
440 $> ipython --profile myprofile
443 $> ipython --profile myprofile
441 # and
444 # and
442 $> ipython --profile='myprofile'
445 $> ipython --profile='myprofile'
443 # are equivalent to
446 # are equivalent to
444 $> ipython --BaseIPythonApplication.profile='myprofile'
447 $> ipython --BaseIPythonApplication.profile='myprofile'
445
448
446 Flags
449 Flags
447 -----
450 -----
448
451
449 Applications can also be passed **flags**. Flags are options that take no
452 Applications can also be passed **flags**. Flags are options that take no
450 arguments. They are simply wrappers for
453 arguments. They are simply wrappers for
451 setting one or more configurables with predefined values, often True/False.
454 setting one or more configurables with predefined values, often True/False.
452
455
453 For instance:
456 For instance:
454
457
455 .. code-block:: bash
458 .. code-block:: bash
456
459
457 $> ipcontroller --debug
460 $> ipcontroller --debug
458 # is equivalent to
461 # is equivalent to
459 $> ipcontroller --Application.log_level=DEBUG
462 $> ipcontroller --Application.log_level=DEBUG
460 # and
463 # and
461 $> ipython --pylab
464 $> ipython --pylab
462 # is equivalent to
465 # is equivalent to
463 $> ipython --pylab=auto
466 $> ipython --pylab=auto
464 # or
467 # or
465 $> ipython --no-banner
468 $> ipython --no-banner
466 # is equivalent to
469 # is equivalent to
467 $> ipython --TerminalIPythonApp.display_banner=False
470 $> ipython --TerminalIPythonApp.display_banner=False
468
471
469 Subcommands
472 Subcommands
470 ***********
473 ***********
471
474
472
475
473 Some IPython applications have **subcommands**. Subcommands are modeled after
476 Some IPython applications have **subcommands**. Subcommands are modeled after
474 :command:`git`, and are called with the form :command:`command subcommand
477 :command:`git`, and are called with the form :command:`command subcommand
475 [...args]`. Currently, the QtConsole is a subcommand of terminal IPython:
478 [...args]`. Currently, the QtConsole is a subcommand of terminal IPython:
476
479
477 .. code-block:: bash
480 .. code-block:: bash
478
481
479 $> ipython qtconsole --profile=myprofile
482 $> ipython qtconsole --profile=myprofile
480
483
481 and :command:`ipcluster` is simply a wrapper for its various subcommands (start,
484 and :command:`ipcluster` is simply a wrapper for its various subcommands (start,
482 stop, engines).
485 stop, engines).
483
486
484 .. code-block:: bash
487 .. code-block:: bash
485
488
486 $> ipcluster start --profile=myprofile --n=4
489 $> ipcluster start --profile=myprofile --n=4
487
490
488
491
489 To see a list of the available aliases, flags, and subcommands for an IPython application, simply pass ``-h`` or ``--help``. And to see the full list of configurable options (*very* long), pass ``--help-all``.
492 To see a list of the available aliases, flags, and subcommands for an IPython application, simply pass ``-h`` or ``--help``. And to see the full list of configurable options (*very* long), pass ``--help-all``.
490
493
491
494
492 Design requirements
495 Design requirements
493 ===================
496 ===================
494
497
495 Here are the main requirements we wanted our configuration system to have:
498 Here are the main requirements we wanted our configuration system to have:
496
499
497 * Support for hierarchical configuration information.
500 * Support for hierarchical configuration information.
498
501
499 * Full integration with command line option parsers. Often, you want to read
502 * Full integration with command line option parsers. Often, you want to read
500 a configuration file, but then override some of the values with command line
503 a configuration file, but then override some of the values with command line
501 options. Our configuration system automates this process and allows each
504 options. Our configuration system automates this process and allows each
502 command line option to be linked to a particular attribute in the
505 command line option to be linked to a particular attribute in the
503 configuration hierarchy that it will override.
506 configuration hierarchy that it will override.
504
507
505 * Configuration files that are themselves valid Python code. This accomplishes
508 * Configuration files that are themselves valid Python code. This accomplishes
506 many things. First, it becomes possible to put logic in your configuration
509 many things. First, it becomes possible to put logic in your configuration
507 files that sets attributes based on your operating system, network setup,
510 files that sets attributes based on your operating system, network setup,
508 Python version, etc. Second, Python has a super simple syntax for accessing
511 Python version, etc. Second, Python has a super simple syntax for accessing
509 hierarchical data structures, namely regular attribute access
512 hierarchical data structures, namely regular attribute access
510 (``Foo.Bar.Bam.name``). Third, using Python makes it easy for users to
513 (``Foo.Bar.Bam.name``). Third, using Python makes it easy for users to
511 import configuration attributes from one configuration file to another.
514 import configuration attributes from one configuration file to another.
512 Fourth, even though Python is dynamically typed, it does have types that can
515 Fourth, even though Python is dynamically typed, it does have types that can
513 be checked at runtime. Thus, a ``1`` in a config file is the integer '1',
516 be checked at runtime. Thus, a ``1`` in a config file is the integer '1',
514 while a ``'1'`` is a string.
517 while a ``'1'`` is a string.
515
518
516 * A fully automated method for getting the configuration information to the
519 * A fully automated method for getting the configuration information to the
517 classes that need it at runtime. Writing code that walks a configuration
520 classes that need it at runtime. Writing code that walks a configuration
518 hierarchy to extract a particular attribute is painful. When you have
521 hierarchy to extract a particular attribute is painful. When you have
519 complex configuration information with hundreds of attributes, this makes
522 complex configuration information with hundreds of attributes, this makes
520 you want to cry.
523 you want to cry.
521
524
522 * Type checking and validation that doesn't require the entire configuration
525 * Type checking and validation that doesn't require the entire configuration
523 hierarchy to be specified statically before runtime. Python is a very
526 hierarchy to be specified statically before runtime. Python is a very
524 dynamic language and you don't always know everything that needs to be
527 dynamic language and you don't always know everything that needs to be
525 configured when a program starts.
528 configured when a program starts.
526
529
527
530
528 .. _`XDG Base Directory`: http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
531 .. _`XDG Base Directory`: http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
@@ -1,24 +1,22 b''
1 .. _plugins_overview:
1 .. _plugins_overview:
2
2
3 ===============
3 ===============
4 IPython plugins
4 IPython plugins
5 ===============
5 ===============
6
6
7 IPython has a plugin mechanism that allows users to create new and custom
7 IPython has a plugin mechanism that allows users to create new and custom
8 runtime components for IPython. Plugins are different from extensions:
8 runtime components for IPython. Plugins are different from extensions:
9
9
10 * Extensions are used to load plugins.
10 * Extensions are used to load plugins.
11 * Extensions are a more advanced configuration system that gives you access
11 * Plugins are a more advanced configuration system that gives you access
12 to the running IPython instance.
12 to the running IPython instance.
13 * Plugins add entirely new capabilities to IPython.
14 * Plugins are traited and configurable.
13 * Plugins are traited and configurable.
15
14
16 At this point, our plugin system is brand new and the documentation is
15 At this point, the documentation of our plugin system is minimal. If you are
17 minimal. If you are interested in creating a new plugin, see the following
16 interested in creating a new plugin, see the following files:
18 files:
19
17
20 * :file:`IPython/extensions/parallelmagic.py`
18 * :file:`IPython/extensions/parallelmagic.py`
21 * :file:`IPython/extensions/autoreload.py`
19 * :file:`IPython/extensions/autoreload.py`
22 * :file:`IPython/extensions/sympyprinting.py`
23
20
24 As well as our documentation on the configuration system and extensions.
21 As well as our documentation on the :ref:`configuration system <config_overview>`
22 and :ref:`extensions <extensions_overview>`.
General Comments 0
You need to be logged in to leave comments. Login now