##// END OF EJS Templates
Update format of command line args in interactive section of docs.
Thomas Kluyver -
Show More
@@ -1,271 +1,271 b''
1 .. _qtconsole:
1 .. _qtconsole:
2
2
3 =========================
3 =========================
4 IPython as a QtGUI widget
4 IPython as a QtGUI widget
5 =========================
5 =========================
6
6
7 We now have a version of IPython, using the new two-process :ref:`ZeroMQ Kernel <ipythonzmq>`,
7 We now have a version of IPython, using the new two-process :ref:`ZeroMQ Kernel <ipythonzmq>`,
8 running in a PyQt_ GUI.
8 running in a PyQt_ GUI.
9
9
10 Overview
10 Overview
11 ========
11 ========
12
12
13 The Qt frontend has hand-coded emacs-style bindings for text navigation. This is not yet
13 The Qt frontend has hand-coded emacs-style bindings for text navigation. This is not yet
14 configurable.
14 configurable.
15
15
16 .. seealso::
16 .. seealso::
17
17
18 :ref:`The original IPython-Qt project description. <ipython_qt>`
18 :ref:`The original IPython-Qt project description. <ipython_qt>`
19
19
20 ``%loadpy``
20 ``%loadpy``
21 ===========
21 ===========
22
22
23 The ``%loadpy`` magic has been added, just for the GUI frontend. It takes any python
23 The new ``%loadpy`` magic takes any python
24 script (must end in '.py'), and pastes its contents as your next input, so you can edit it
24 script (must end in '.py'), and pastes its contents as your next input, so you can edit it
25 before executing. The script may be on your machine, but you can also specify a url, and
25 before executing. The script may be on your machine, but you can also specify a url, and
26 it will download the script from the web. This is particularly useful for playing with
26 it will download the script from the web. This is particularly useful for playing with
27 examples from documentation, such as matplotlib.
27 examples from documentation, such as matplotlib.
28
28
29 .. sourcecode:: ipython
29 .. sourcecode:: ipython
30
30
31 In [6]: %loadpy
31 In [6]: %loadpy http://matplotlib.sourceforge.net/plot_directive/mpl_examples/mplot3d/contour3d_demo.py
32 http://matplotlib.sourceforge.net/plot_directive/mpl_examples/mplot3d/contour3d_demo.py
33
32
34 In [7]: from mpl_toolkits.mplot3d import axes3d
33 In [7]: from mpl_toolkits.mplot3d import axes3d
35 ...: import matplotlib.pyplot as plt
34 ...: import matplotlib.pyplot as plt
36 ...:
35 ...:
37 ...: fig = plt.figure()
36 ...: fig = plt.figure()
38 ...: ax = fig.add_subplot(111, projection='3d')
37 ...: ax = fig.add_subplot(111, projection='3d')
39 ...: X, Y, Z = axes3d.get_test_data(0.05)
38 ...: X, Y, Z = axes3d.get_test_data(0.05)
40 ...: cset = ax.contour(X, Y, Z)
39 ...: cset = ax.contour(X, Y, Z)
41 ...: ax.clabel(cset, fontsize=9, inline=1)
40 ...: ax.clabel(cset, fontsize=9, inline=1)
42 ...:
41 ...:
43 ...: plt.show()
42 ...: plt.show()
44
43
45 Pylab
44 Pylab
46 =====
45 =====
47
46
48 One of the most exciting features of the new console is embedded matplotlib figures. You
47 One of the most exciting features of the new console is embedded matplotlib figures. You
49 can use any standard matplotlib GUI backend (Except native MacOSX) to draw the figures,
48 can use any standard matplotlib GUI backend (Except native MacOSX) to draw the figures,
50 and since there is now a two-process model, there is no longer a conflict between user
49 and since there is now a two-process model, there is no longer a conflict between user
51 input and the drawing eventloop.
50 input and the drawing eventloop.
52
51
53 .. image:: figs/besselj.png
52 .. image:: figs/besselj.png
54 :width: 519px
53 :width: 519px
55
54
56 .. pastefig:
55 .. pastefig:
57
56
58 :func:`pastefig`
57 :func:`pastefig`
59 ****************
58 ****************
60
59
61 An additional function, :func:`pastefig`, will be added to the global namespace if you
60 An additional function, :func:`pastefig`, will be added to the global namespace if you
62 specify the ``pylab`` argument. This takes the active figures in matplotlib, and embeds
61 specify the ``pylab`` argument. This takes the active figures in matplotlib, and embeds
63 them in your document. This is especially useful for saving_ your work.
62 them in your document. This is especially useful for saving_ your work.
64
63
65 .. _inline:
64 .. _inline:
66
65
67 ``pylab=inline``
66 ``--pylab=inline``
68 ******************
67 ******************
69
68
70 If you want to have all of your figures embedded in your session, instead of calling
69 If you want to have all of your figures embedded in your session, instead of calling
71 :func:`pastefig`, you can specify ``pylab=inline``, and each time you make a plot, it
70 :func:`pastefig`, you can specify ``--pylab=inline`` when you start the console,
72 will show up in your document, as if you had called :func:`pastefig`.
71 and each time you make a plot, it will show up in your document, as if you had
72 called :func:`pastefig`.
73
73
74
74
75 .. _saving:
75 .. _saving:
76
76
77 Saving and Printing
77 Saving and Printing
78 ===================
78 ===================
79
79
80 IPythonQt has the ability to save your current session, as either HTML or XHTML. If you
80 IPythonQt has the ability to save your current session, as either HTML or XHTML. If you
81 have been using :func:`pastefig` or inline_ pylab, your figures will be PNG
81 have been using :func:`pastefig` or inline_ pylab, your figures will be PNG
82 in HTML, or inlined as SVG in XHTML. PNG images have the option to be either in an
82 in HTML, or inlined as SVG in XHTML. PNG images have the option to be either in an
83 external folder, as in many browsers' "Webpage, Complete" option, or inlined as well, for
83 external folder, as in many browsers' "Webpage, Complete" option, or inlined as well, for
84 a larger, but more portable file.
84 a larger, but more portable file.
85
85
86 The widget also exposes the ability to print directly, via the default print shortcut or
86 The widget also exposes the ability to print directly, via the default print shortcut or
87 context menu.
87 context menu.
88
88
89
89
90 .. Note::
90 .. Note::
91
91
92 Saving is only available to richtext Qt widgets, which are used by default, but
92 Saving is only available to richtext Qt widgets, which are used by default, but
93 if you pass the ``--plain`` flag, saving will not be available to you.
93 if you pass the ``--plain`` flag, saving will not be available to you.
94
94
95
95
96 See these examples of :download:`png/html<figs/jn.html>` and :download:`svg/xhtml
96 See these examples of :download:`png/html<figs/jn.html>` and :download:`svg/xhtml
97 <figs/jn.xhtml>` output. Note that syntax highlighting does not survive export. This is a known
97 <figs/jn.xhtml>` output. Note that syntax highlighting does not survive export. This is a known
98 issue, and is being investigated.
98 issue, and is being investigated.
99
99
100 Colors and Highlighting
100 Colors and Highlighting
101 =======================
101 =======================
102
102
103 Terminal IPython has always had some coloring, but never syntax highlighting. There are a
103 Terminal IPython has always had some coloring, but never syntax highlighting. There are a
104 few simple color choices, specified by the ``colors`` flag or ``%colors`` magic:
104 few simple color choices, specified by the ``colors`` flag or ``%colors`` magic:
105
105
106 * LightBG for light backgrounds
106 * LightBG for light backgrounds
107 * Linux for dark backgrounds
107 * Linux for dark backgrounds
108 * NoColor for a simple colorless terminal
108 * NoColor for a simple colorless terminal
109
109
110 The Qt widget has full support for the ``colors`` flag used in the terminal shell.
110 The Qt widget has full support for the ``colors`` flag used in the terminal shell.
111
111
112 The Qt widget, however, has full syntax highlighting as you type, handled by the
112 The Qt widget, however, has full syntax highlighting as you type, handled by the
113 `pygments`_ library. The ``style`` argument exposes access to any style by name that can
113 `pygments`_ library. The ``style`` argument exposes access to any style by name that can
114 be found by pygments, and there are several already installed. The ``colors`` argument,
114 be found by pygments, and there are several already installed. The ``colors`` argument,
115 if unspecified, will be guessed based on the chosen style. Similarly, there are default
115 if unspecified, will be guessed based on the chosen style. Similarly, there are default
116 styles associated with each ``colors`` option.
116 styles associated with each ``colors`` option.
117
117
118
118
119 Screenshot of ``ipython qtconsole colors=linux``, which uses the 'monokai' theme by
119 Screenshot of ``ipython qtconsole --colors=linux``, which uses the 'monokai' theme by
120 default:
120 default:
121
121
122 .. image:: figs/colors_dark.png
122 .. image:: figs/colors_dark.png
123 :width: 627px
123 :width: 627px
124
124
125 .. Note::
125 .. Note::
126
126
127 Calling ``ipython qtconsole -h`` will show all the style names that pygments can find
127 Calling ``ipython qtconsole -h`` will show all the style names that pygments can find
128 on your system.
128 on your system.
129
129
130 You can also pass the filename of a custom CSS stylesheet, if you want to do your own
130 You can also pass the filename of a custom CSS stylesheet, if you want to do your own
131 coloring, via the ``stylesheet`` argument. The default LightBG stylesheet:
131 coloring, via the ``stylesheet`` argument. The default LightBG stylesheet:
132
132
133 .. sourcecode:: css
133 .. sourcecode:: css
134
134
135 QPlainTextEdit, QTextEdit { background-color: white;
135 QPlainTextEdit, QTextEdit { background-color: white;
136 color: black ;
136 color: black ;
137 selection-background-color: #ccc}
137 selection-background-color: #ccc}
138 .error { color: red; }
138 .error { color: red; }
139 .in-prompt { color: navy; }
139 .in-prompt { color: navy; }
140 .in-prompt-number { font-weight: bold; }
140 .in-prompt-number { font-weight: bold; }
141 .out-prompt { color: darkred; }
141 .out-prompt { color: darkred; }
142 .out-prompt-number { font-weight: bold; }
142 .out-prompt-number { font-weight: bold; }
143
143
144 Fonts
144 Fonts
145 =====
145 =====
146
146
147 The QtConsole has configurable via the ConsoleWidget. To change these, set the ``font_family``
147 The QtConsole has configurable via the ConsoleWidget. To change these, set the ``font_family``
148 or ``font_size`` traits of the ConsoleWidget. For instance, to use 9pt Anonymous Pro::
148 or ``font_size`` traits of the ConsoleWidget. For instance, to use 9pt Anonymous Pro::
149
149
150 $> ipython qtconsole ConsoleWidget.font_family="Anonymous Pro" ConsoleWidget.font_size=9
150 $> ipython qtconsole --ConsoleWidget.font_family="Anonymous Pro" --ConsoleWidget.font_size=9
151
151
152 Process Management
152 Process Management
153 ==================
153 ==================
154
154
155 With the two-process ZMQ model, the frontend does not block input during execution. This
155 With the two-process ZMQ model, the frontend does not block input during execution. This
156 means that actions can be taken by the frontend while the Kernel is executing, or even
156 means that actions can be taken by the frontend while the Kernel is executing, or even
157 after it crashes. The most basic such command is via 'Ctrl-.', which restarts the kernel.
157 after it crashes. The most basic such command is via 'Ctrl-.', which restarts the kernel.
158 This can be done in the middle of a blocking execution. The frontend can also know, via a
158 This can be done in the middle of a blocking execution. The frontend can also know, via a
159 heartbeat mechanism, that the kernel has died. This means that the frontend can safely
159 heartbeat mechanism, that the kernel has died. This means that the frontend can safely
160 restart the kernel.
160 restart the kernel.
161
161
162 Multiple Consoles
162 Multiple Consoles
163 *****************
163 *****************
164
164
165 Since the Kernel listens on the network, multiple frontends can connect to it. These
165 Since the Kernel listens on the network, multiple frontends can connect to it. These
166 do not have to all be qt frontends - any IPython frontend can connect and run code.
166 do not have to all be qt frontends - any IPython frontend can connect and run code.
167 When you start ipython qtconsole, there will be an output line, like::
167 When you start ipython qtconsole, there will be an output line, like::
168
168
169 To connect another client to this kernel, use:
169 To connect another client to this kernel, use:
170 --external shell=62109 iopub=62110 stdin=62111 hb=62112
170 --external --shell=62109 --iopub=62110 --stdin=62111 --hb=62112
171
171
172 Other frontends can connect to your kernel, and share in the execution. This is great for
172 Other frontends can connect to your kernel, and share in the execution. This is great for
173 collaboration. The `-e` flag is for 'external'. Starting other consoles with that flag
173 collaboration. The `-e` flag is for 'external'. Starting other consoles with that flag
174 will not try to start their own, but rather connect to yours. Ultimately, you will not
174 will not try to start their own, but rather connect to yours. Ultimately, you will not
175 have to specify each port individually, but for now this copy-paste method is best.
175 have to specify each port individually, but for now this copy-paste method is best.
176
176
177 By default (for security reasons), the kernel only listens on localhost, so you can only
177 By default (for security reasons), the kernel only listens on localhost, so you can only
178 connect multiple frontends to the kernel from your local machine. You can specify to
178 connect multiple frontends to the kernel from your local machine. You can specify to
179 listen on an external interface by specifying the ``ip`` argument::
179 listen on an external interface by specifying the ``ip`` argument::
180
180
181 $> ipython qtconsole ip=192.168.1.123
181 $> ipython qtconsole --ip=192.168.1.123
182
182
183 If you specify the ip as 0.0.0.0, that refers to all interfaces, so any computer that can
183 If you specify the ip as 0.0.0.0, that refers to all interfaces, so any computer that can
184 see yours can connect to the kernel.
184 see yours can connect to the kernel.
185
185
186 .. warning::
186 .. warning::
187
187
188 Since the ZMQ code currently has no security, listening on an external-facing IP
188 Since the ZMQ code currently has no security, listening on an external-facing IP
189 is dangerous. You are giving any computer that can see you on the network the ability
189 is dangerous. You are giving any computer that can see you on the network the ability
190 to issue arbitrary shell commands as you on your machine. Be very careful with this.
190 to issue arbitrary shell commands as you on your machine. Be very careful with this.
191
191
192
192
193 Stopping Kernels and Consoles
193 Stopping Kernels and Consoles
194 *****************************
194 *****************************
195
195
196 Since there can be many consoles per kernel, the shutdown mechanism and dialog are
196 Since there can be many consoles per kernel, the shutdown mechanism and dialog are
197 probably more complicated than you are used to. Since you don't always want to shutdown a
197 probably more complicated than you are used to. Since you don't always want to shutdown a
198 kernel when you close a window, you are given the option to just close the console window
198 kernel when you close a window, you are given the option to just close the console window
199 or also close the Kernel and *all other windows*. Note that this only refers to all other
199 or also close the Kernel and *all other windows*. Note that this only refers to all other
200 *local* windows, as remote Consoles are not allowed to shutdown the kernel, and shutdowns
200 *local* windows, as remote Consoles are not allowed to shutdown the kernel, and shutdowns
201 do not close Remote consoles (to allow for saving, etc.).
201 do not close Remote consoles (to allow for saving, etc.).
202
202
203 Rules:
203 Rules:
204
204
205 * Restarting the kernel automatically clears all *local* Consoles, and prompts remote
205 * Restarting the kernel automatically clears all *local* Consoles, and prompts remote
206 Consoles about the reset.
206 Consoles about the reset.
207 * Shutdown closes all *local* Consoles, and notifies remotes that
207 * Shutdown closes all *local* Consoles, and notifies remotes that
208 the Kernel has been shutdown.
208 the Kernel has been shutdown.
209 * Remote Consoles may not restart or shutdown the kernel.
209 * Remote Consoles may not restart or shutdown the kernel.
210
210
211 Qt and the QtConsole
211 Qt and the QtConsole
212 ====================
212 ====================
213
213
214 An important part of working with the QtConsole when you are writing your own Qt code is
214 An important part of working with the QtConsole when you are writing your own Qt code is
215 to remember that user code (in the kernel) is *not* in the same process as the frontend.
215 to remember that user code (in the kernel) is *not* in the same process as the frontend.
216 This means that there is not necessarily any Qt code running in the kernel, and under most
216 This means that there is not necessarily any Qt code running in the kernel, and under most
217 normal circumstances there isn't. If, however, you specify ``pylab=qt`` at the
217 normal circumstances there isn't. If, however, you specify ``pylab=qt`` at the
218 command-line, then there *will* be a :class:`QCoreApplication` instance running in the
218 command-line, then there *will* be a :class:`QCoreApplication` instance running in the
219 kernel process along with user-code. To get a reference to this application, do:
219 kernel process along with user-code. To get a reference to this application, do:
220
220
221 .. sourcecode:: python
221 .. sourcecode:: python
222
222
223 from PyQt4 import QtCore
223 from PyQt4 import QtCore
224 app = QtCore.QCoreApplication.instance()
224 app = QtCore.QCoreApplication.instance()
225 # app will be None if there is no such instance
225 # app will be None if there is no such instance
226
226
227 A common problem listed in the PyQt4 Gotchas_ is the fact that Python's garbage collection
227 A common problem listed in the PyQt4 Gotchas_ is the fact that Python's garbage collection
228 will destroy Qt objects (Windows, etc.) once there is no longer a Python reference to
228 will destroy Qt objects (Windows, etc.) once there is no longer a Python reference to
229 them, so you have to hold on to them. For instance, in:
229 them, so you have to hold on to them. For instance, in:
230
230
231 .. sourcecode:: python
231 .. sourcecode:: python
232
232
233 def make_window():
233 def make_window():
234 win = QtGui.QMainWindow()
234 win = QtGui.QMainWindow()
235
235
236 def make_and_return_window():
236 def make_and_return_window():
237 win = QtGui.QMainWindow()
237 win = QtGui.QMainWindow()
238 return win
238 return win
239
239
240 :func:`make_window` will never draw a window, because garbage collection will destroy it
240 :func:`make_window` will never draw a window, because garbage collection will destroy it
241 before it is drawn, whereas :func:`make_and_return_window` lets the caller decide when the
241 before it is drawn, whereas :func:`make_and_return_window` lets the caller decide when the
242 window object should be destroyed. If, as a developer, you know that you always want your
242 window object should be destroyed. If, as a developer, you know that you always want your
243 objects to last as long as the process, you can attach them to the QApplication instance
243 objects to last as long as the process, you can attach them to the QApplication instance
244 itself:
244 itself:
245
245
246 .. sourcecode:: python
246 .. sourcecode:: python
247
247
248 # do this just once:
248 # do this just once:
249 app = QtCore.QCoreApplication.instance()
249 app = QtCore.QCoreApplication.instance()
250 app.references = set()
250 app.references = set()
251 # then when you create Windows, add them to the set
251 # then when you create Windows, add them to the set
252 def make_window():
252 def make_window():
253 win = QtGui.QMainWindow()
253 win = QtGui.QMainWindow()
254 app.references.add(win)
254 app.references.add(win)
255
255
256 Now the QApplication itself holds a reference to ``win``, so it will never be
256 Now the QApplication itself holds a reference to ``win``, so it will never be
257 garbage collected until the application itself is destroyed.
257 garbage collected until the application itself is destroyed.
258
258
259 .. _Gotchas: http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/gotchas.html#garbage-collection
259 .. _Gotchas: http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/gotchas.html#garbage-collection
260
260
261 Regressions
261 Regressions
262 ===========
262 ===========
263
263
264 There are some features, where the qt console lags behind the Terminal frontend. We hope
264 There are some features, where the qt console lags behind the Terminal frontend. We hope
265 to have these fixed by 0.11 release.
265 to have these fixed by 0.11 release.
266
266
267 * !cmd input: Due to our use of pexpect, we cannot pass input to subprocesses launched
267 * !cmd input: Due to our use of pexpect, we cannot pass input to subprocesses launched
268 using the '!' escape. (this will not be fixed).
268 using the '!' escape. (this will not be fixed).
269
269
270 .. [PyQt] PyQt4 http://www.riverbankcomputing.co.uk/software/pyqt/download
270 .. [PyQt] PyQt4 http://www.riverbankcomputing.co.uk/software/pyqt/download
271 .. [pygments] Pygments http://pygments.org/
271 .. [pygments] Pygments http://pygments.org/
@@ -1,1385 +1,1385 b''
1 =================
1 =================
2 IPython reference
2 IPython reference
3 =================
3 =================
4
4
5 .. _command_line_options:
5 .. _command_line_options:
6
6
7 Command-line usage
7 Command-line usage
8 ==================
8 ==================
9
9
10 You start IPython with the command::
10 You start IPython with the command::
11
11
12 $ ipython [options] files
12 $ ipython [options] files
13
13
14 If invoked with no options, it executes all the files listed in sequence
14 If invoked with no options, it executes all the files listed in sequence
15 and drops you into the interpreter while still acknowledging any options
15 and drops you into the interpreter while still acknowledging any options
16 you may have set in your ipython_config.py. This behavior is different from
16 you may have set in your ipython_config.py. This behavior is different from
17 standard Python, which when called as python -i will only execute one
17 standard Python, which when called as python -i will only execute one
18 file and ignore your configuration setup.
18 file and ignore your configuration setup.
19
19
20 Please note that some of the configuration options are not available at
20 Please note that some of the configuration options are not available at
21 the command line, simply because they are not practical here. Look into
21 the command line, simply because they are not practical here. Look into
22 your ipythonrc configuration file for details on those. This file is typically
22 your ipythonrc configuration file for details on those. This file is typically
23 installed in the IPYTHON_DIR directory. For Linux
23 installed in the IPYTHON_DIR directory. For Linux
24 users, this will be $HOME/.config/ipython, and for other users it will be
24 users, this will be $HOME/.config/ipython, and for other users it will be
25 $HOME/.ipython. For Windows users, $HOME resolves to C:\\Documents and
25 $HOME/.ipython. For Windows users, $HOME resolves to C:\\Documents and
26 Settings\\YourUserName in most instances.
26 Settings\\YourUserName in most instances.
27
27
28
28
29 Eventloop integration
29 Eventloop integration
30 ---------------------
30 ---------------------
31
31
32 Previously IPython had command line options for controlling GUI event loop
32 Previously IPython had command line options for controlling GUI event loop
33 integration (-gthread, -qthread, -q4thread, -wthread, -pylab). As of IPython
33 integration (-gthread, -qthread, -q4thread, -wthread, -pylab). As of IPython
34 version 0.11, these have been removed. Please see the new ``%gui``
34 version 0.11, these have been removed. Please see the new ``%gui``
35 magic command or :ref:`this section <gui_support>` for details on the new
35 magic command or :ref:`this section <gui_support>` for details on the new
36 interface, or specify the gui at the commandline::
36 interface, or specify the gui at the commandline::
37
37
38 $ ipython gui=qt
38 $ ipython --gui=qt
39
39
40
40
41 Regular Options
41 Regular Options
42 ---------------
42 ---------------
43
43
44 After the above threading options have been given, regular options can
44 After the above threading options have been given, regular options can
45 follow in any order. All options can be abbreviated to their shortest
45 follow in any order. All options can be abbreviated to their shortest
46 non-ambiguous form and are case-sensitive. One or two dashes can be
46 non-ambiguous form and are case-sensitive. One or two dashes can be
47 used. Some options have an alternate short form, indicated after a ``|``.
47 used. Some options have an alternate short form, indicated after a ``|``.
48
48
49 Most options can also be set from your ipythonrc configuration file. See
49 Most options can also be set from your ipythonrc configuration file. See
50 the provided example for more details on what the options do. Options
50 the provided example for more details on what the options do. Options
51 given at the command line override the values set in the ipythonrc file.
51 given at the command line override the values set in the ipythonrc file.
52
52
53 All options with a [no] prepended can be specified in negated form
53 All options with a [no] prepended can be specified in negated form
54 (--no-option instead of --option) to turn the feature off.
54 (--no-option instead of --option) to turn the feature off.
55
55
56 ``-h, --help`` print a help message and exit.
56 ``-h, --help`` print a help message and exit.
57
57
58 ``--pylab, pylab=<name>``
58 ``--pylab, pylab=<name>``
59 See :ref:`Matplotlib support <matplotlib_support>`
59 See :ref:`Matplotlib support <matplotlib_support>`
60 for more details.
60 for more details.
61
61
62 ``autocall=<val>``
62 ``--autocall=<val>``
63 Make IPython automatically call any callable object even if you
63 Make IPython automatically call any callable object even if you
64 didn't type explicit parentheses. For example, 'str 43' becomes
64 didn't type explicit parentheses. For example, 'str 43' becomes
65 'str(43)' automatically. The value can be '0' to disable the feature,
65 'str(43)' automatically. The value can be '0' to disable the feature,
66 '1' for smart autocall, where it is not applied if there are no more
66 '1' for smart autocall, where it is not applied if there are no more
67 arguments on the line, and '2' for full autocall, where all callable
67 arguments on the line, and '2' for full autocall, where all callable
68 objects are automatically called (even if no arguments are
68 objects are automatically called (even if no arguments are
69 present). The default is '1'.
69 present). The default is '1'.
70
70
71 ``--[no-]autoindent``
71 ``--[no-]autoindent``
72 Turn automatic indentation on/off.
72 Turn automatic indentation on/off.
73
73
74 ``--[no-]automagic``
74 ``--[no-]automagic``
75 make magic commands automatic (without needing their first character
75 make magic commands automatic (without needing their first character
76 to be %). Type %magic at the IPython prompt for more information.
76 to be %). Type %magic at the IPython prompt for more information.
77
77
78 ``--[no-]autoedit_syntax``
78 ``--[no-]autoedit_syntax``
79 When a syntax error occurs after editing a file, automatically
79 When a syntax error occurs after editing a file, automatically
80 open the file to the trouble causing line for convenient
80 open the file to the trouble causing line for convenient
81 fixing.
81 fixing.
82
82
83 ``--[no-]banner``
83 ``--[no-]banner``
84 Print the initial information banner (default on).
84 Print the initial information banner (default on).
85
85
86 ``c=<command>``
86 ``--c=<command>``
87 execute the given command string. This is similar to the -c
87 execute the given command string. This is similar to the -c
88 option in the normal Python interpreter.
88 option in the normal Python interpreter.
89
89
90 ``cache_size=<n>``
90 ``--cache_size=<n>``
91 size of the output cache (maximum number of entries to hold in
91 size of the output cache (maximum number of entries to hold in
92 memory). The default is 1000, you can change it permanently in your
92 memory). The default is 1000, you can change it permanently in your
93 config file. Setting it to 0 completely disables the caching system,
93 config file. Setting it to 0 completely disables the caching system,
94 and the minimum value accepted is 20 (if you provide a value less than
94 and the minimum value accepted is 20 (if you provide a value less than
95 20, it is reset to 0 and a warning is issued) This limit is defined
95 20, it is reset to 0 and a warning is issued) This limit is defined
96 because otherwise you'll spend more time re-flushing a too small cache
96 because otherwise you'll spend more time re-flushing a too small cache
97 than working.
97 than working.
98
98
99 ``--classic``
99 ``--classic``
100 Gives IPython a similar feel to the classic Python
100 Gives IPython a similar feel to the classic Python
101 prompt.
101 prompt.
102
102
103 ``colors=<scheme>``
103 ``--colors=<scheme>``
104 Color scheme for prompts and exception reporting. Currently
104 Color scheme for prompts and exception reporting. Currently
105 implemented: NoColor, Linux and LightBG.
105 implemented: NoColor, Linux and LightBG.
106
106
107 ``--[no-]color_info``
107 ``--[no-]color_info``
108 IPython can display information about objects via a set of functions,
108 IPython can display information about objects via a set of functions,
109 and optionally can use colors for this, syntax highlighting source
109 and optionally can use colors for this, syntax highlighting source
110 code and various other elements. However, because this information is
110 code and various other elements. However, because this information is
111 passed through a pager (like 'less') and many pagers get confused with
111 passed through a pager (like 'less') and many pagers get confused with
112 color codes, this option is off by default. You can test it and turn
112 color codes, this option is off by default. You can test it and turn
113 it on permanently in your ipythonrc file if it works for you. As a
113 it on permanently in your ipythonrc file if it works for you. As a
114 reference, the 'less' pager supplied with Mandrake 8.2 works ok, but
114 reference, the 'less' pager supplied with Mandrake 8.2 works ok, but
115 that in RedHat 7.2 doesn't.
115 that in RedHat 7.2 doesn't.
116
116
117 Test it and turn it on permanently if it works with your
117 Test it and turn it on permanently if it works with your
118 system. The magic function %color_info allows you to toggle this
118 system. The magic function %color_info allows you to toggle this
119 interactively for testing.
119 interactively for testing.
120
120
121 ``--[no-]debug``
121 ``--[no-]debug``
122 Show information about the loading process. Very useful to pin down
122 Show information about the loading process. Very useful to pin down
123 problems with your configuration files or to get details about
123 problems with your configuration files or to get details about
124 session restores.
124 session restores.
125
125
126 ``--[no-]deep_reload``
126 ``--[no-]deep_reload``
127 IPython can use the deep_reload module which reloads changes in
127 IPython can use the deep_reload module which reloads changes in
128 modules recursively (it replaces the reload() function, so you don't
128 modules recursively (it replaces the reload() function, so you don't
129 need to change anything to use it). deep_reload() forces a full
129 need to change anything to use it). deep_reload() forces a full
130 reload of modules whose code may have changed, which the default
130 reload of modules whose code may have changed, which the default
131 reload() function does not.
131 reload() function does not.
132
132
133 When deep_reload is off, IPython will use the normal reload(),
133 When deep_reload is off, IPython will use the normal reload(),
134 but deep_reload will still be available as dreload(). This
134 but deep_reload will still be available as dreload(). This
135 feature is off by default [which means that you have both
135 feature is off by default [which means that you have both
136 normal reload() and dreload()].
136 normal reload() and dreload()].
137
137
138 ``editor=<name>``
138 ``--editor=<name>``
139 Which editor to use with the %edit command. By default,
139 Which editor to use with the %edit command. By default,
140 IPython will honor your EDITOR environment variable (if not
140 IPython will honor your EDITOR environment variable (if not
141 set, vi is the Unix default and notepad the Windows one).
141 set, vi is the Unix default and notepad the Windows one).
142 Since this editor is invoked on the fly by IPython and is
142 Since this editor is invoked on the fly by IPython and is
143 meant for editing small code snippets, you may want to use a
143 meant for editing small code snippets, you may want to use a
144 small, lightweight editor here (in case your default EDITOR is
144 small, lightweight editor here (in case your default EDITOR is
145 something like Emacs).
145 something like Emacs).
146
146
147 ``ipython_dir=<name>``
147 ``--ipython_dir=<name>``
148 name of your IPython configuration directory IPYTHON_DIR. This
148 name of your IPython configuration directory IPYTHON_DIR. This
149 can also be specified through the environment variable
149 can also be specified through the environment variable
150 IPYTHON_DIR.
150 IPYTHON_DIR.
151
151
152 ``logfile=<name>``
152 ``--logfile=<name>``
153 specify the name of your logfile.
153 specify the name of your logfile.
154
154
155 This implies ``%logstart`` at the beginning of your session
155 This implies ``%logstart`` at the beginning of your session
156
156
157 generate a log file of all input. The file is named
157 generate a log file of all input. The file is named
158 ipython_log.py in your current directory (which prevents logs
158 ipython_log.py in your current directory (which prevents logs
159 from multiple IPython sessions from trampling each other). You
159 from multiple IPython sessions from trampling each other). You
160 can use this to later restore a session by loading your
160 can use this to later restore a session by loading your
161 logfile with ``ipython --i ipython_log.py``
161 logfile with ``ipython --i ipython_log.py``
162
162
163 ``logplay=<name>``
163 ``--logplay=<name>``
164
164
165 NOT AVAILABLE in 0.11
165 NOT AVAILABLE in 0.11
166
166
167 you can replay a previous log. For restoring a session as close as
167 you can replay a previous log. For restoring a session as close as
168 possible to the state you left it in, use this option (don't just run
168 possible to the state you left it in, use this option (don't just run
169 the logfile). With -logplay, IPython will try to reconstruct the
169 the logfile). With -logplay, IPython will try to reconstruct the
170 previous working environment in full, not just execute the commands in
170 previous working environment in full, not just execute the commands in
171 the logfile.
171 the logfile.
172
172
173 When a session is restored, logging is automatically turned on
173 When a session is restored, logging is automatically turned on
174 again with the name of the logfile it was invoked with (it is
174 again with the name of the logfile it was invoked with (it is
175 read from the log header). So once you've turned logging on for
175 read from the log header). So once you've turned logging on for
176 a session, you can quit IPython and reload it as many times as
176 a session, you can quit IPython and reload it as many times as
177 you want and it will continue to log its history and restore
177 you want and it will continue to log its history and restore
178 from the beginning every time.
178 from the beginning every time.
179
179
180 Caveats: there are limitations in this option. The history
180 Caveats: there are limitations in this option. The history
181 variables _i*,_* and _dh don't get restored properly. In the
181 variables _i*,_* and _dh don't get restored properly. In the
182 future we will try to implement full session saving by writing
182 future we will try to implement full session saving by writing
183 and retrieving a 'snapshot' of the memory state of IPython. But
183 and retrieving a 'snapshot' of the memory state of IPython. But
184 our first attempts failed because of inherent limitations of
184 our first attempts failed because of inherent limitations of
185 Python's Pickle module, so this may have to wait.
185 Python's Pickle module, so this may have to wait.
186
186
187 ``--[no-]messages``
187 ``--[no-]messages``
188 Print messages which IPython collects about its startup
188 Print messages which IPython collects about its startup
189 process (default on).
189 process (default on).
190
190
191 ``--[no-]pdb``
191 ``--[no-]pdb``
192 Automatically call the pdb debugger after every uncaught
192 Automatically call the pdb debugger after every uncaught
193 exception. If you are used to debugging using pdb, this puts
193 exception. If you are used to debugging using pdb, this puts
194 you automatically inside of it after any call (either in
194 you automatically inside of it after any call (either in
195 IPython or in code called by it) which triggers an exception
195 IPython or in code called by it) which triggers an exception
196 which goes uncaught.
196 which goes uncaught.
197
197
198 ``--[no-]pprint``
198 ``--[no-]pprint``
199 ipython can optionally use the pprint (pretty printer) module
199 ipython can optionally use the pprint (pretty printer) module
200 for displaying results. pprint tends to give a nicer display
200 for displaying results. pprint tends to give a nicer display
201 of nested data structures. If you like it, you can turn it on
201 of nested data structures. If you like it, you can turn it on
202 permanently in your config file (default off).
202 permanently in your config file (default off).
203
203
204 ``profile=<name>``
204 ``--profile=<name>``
205
205
206 Select the IPython profile by name.
206 Select the IPython profile by name.
207
207
208 This is a quick way to keep and load multiple
208 This is a quick way to keep and load multiple
209 config files for different tasks, especially if you use the
209 config files for different tasks, especially if you use the
210 include option of config files. You can keep a basic
210 include option of config files. You can keep a basic
211 :file:`IPYTHON_DIR/profile_default/ipython_config.py` file
211 :file:`IPYTHON_DIR/profile_default/ipython_config.py` file
212 and then have other 'profiles' which
212 and then have other 'profiles' which
213 include this one and load extra things for particular
213 include this one and load extra things for particular
214 tasks. For example:
214 tasks. For example:
215
215
216 1. $IPYTHON_DIR/profile_default : load basic things you always want.
216 1. $IPYTHON_DIR/profile_default : load basic things you always want.
217 2. $IPYTHON_DIR/profile_math : load (1) and basic math-related modules.
217 2. $IPYTHON_DIR/profile_math : load (1) and basic math-related modules.
218 3. $IPYTHON_DIR/profile_numeric : load (1) and Numeric and plotting modules.
218 3. $IPYTHON_DIR/profile_numeric : load (1) and Numeric and plotting modules.
219
219
220 Since it is possible to create an endless loop by having
220 Since it is possible to create an endless loop by having
221 circular file inclusions, IPython will stop if it reaches 15
221 circular file inclusions, IPython will stop if it reaches 15
222 recursive inclusions.
222 recursive inclusions.
223
223
224 ``InteractiveShell.prompt_in1=<string>``
224 ``InteractiveShell.prompt_in1=<string>``
225
225
226 Specify the string used for input prompts. Note that if you are using
226 Specify the string used for input prompts. Note that if you are using
227 numbered prompts, the number is represented with a '\#' in the
227 numbered prompts, the number is represented with a '\#' in the
228 string. Don't forget to quote strings with spaces embedded in
228 string. Don't forget to quote strings with spaces embedded in
229 them. Default: 'In [\#]:'. The :ref:`prompts section <prompts>`
229 them. Default: 'In [\#]:'. The :ref:`prompts section <prompts>`
230 discusses in detail all the available escapes to customize your
230 discusses in detail all the available escapes to customize your
231 prompts.
231 prompts.
232
232
233 ``InteractiveShell.prompt_in2=<string>``
233 ``InteractiveShell.prompt_in2=<string>``
234 Similar to the previous option, but used for the continuation
234 Similar to the previous option, but used for the continuation
235 prompts. The special sequence '\D' is similar to '\#', but
235 prompts. The special sequence '\D' is similar to '\#', but
236 with all digits replaced dots (so you can have your
236 with all digits replaced dots (so you can have your
237 continuation prompt aligned with your input prompt). Default:
237 continuation prompt aligned with your input prompt). Default:
238 ' .\D.:' (note three spaces at the start for alignment with
238 ' .\D.:' (note three spaces at the start for alignment with
239 'In [\#]').
239 'In [\#]').
240
240
241 ``InteractiveShell.prompt_out=<string>``
241 ``InteractiveShell.prompt_out=<string>``
242 String used for output prompts, also uses numbers like
242 String used for output prompts, also uses numbers like
243 prompt_in1. Default: 'Out[\#]:'
243 prompt_in1. Default: 'Out[\#]:'
244
244
245 ``--quick``
245 ``--quick``
246 start in bare bones mode (no config file loaded).
246 start in bare bones mode (no config file loaded).
247
247
248 ``config_file=<name>``
248 ``config_file=<name>``
249 name of your IPython resource configuration file. Normally
249 name of your IPython resource configuration file. Normally
250 IPython loads ipython_config.py (from current directory) or
250 IPython loads ipython_config.py (from current directory) or
251 IPYTHON_DIR/profile_default.
251 IPYTHON_DIR/profile_default.
252
252
253 If the loading of your config file fails, IPython starts with
253 If the loading of your config file fails, IPython starts with
254 a bare bones configuration (no modules loaded at all).
254 a bare bones configuration (no modules loaded at all).
255
255
256 ``--[no-]readline``
256 ``--[no-]readline``
257 use the readline library, which is needed to support name
257 use the readline library, which is needed to support name
258 completion and command history, among other things. It is
258 completion and command history, among other things. It is
259 enabled by default, but may cause problems for users of
259 enabled by default, but may cause problems for users of
260 X/Emacs in Python comint or shell buffers.
260 X/Emacs in Python comint or shell buffers.
261
261
262 Note that X/Emacs 'eterm' buffers (opened with M-x term) support
262 Note that X/Emacs 'eterm' buffers (opened with M-x term) support
263 IPython's readline and syntax coloring fine, only 'emacs' (M-x
263 IPython's readline and syntax coloring fine, only 'emacs' (M-x
264 shell and C-c !) buffers do not.
264 shell and C-c !) buffers do not.
265
265
266 ``TerminalInteractiveShell.screen_length=<n>``
266 ``--TerminalInteractiveShell.screen_length=<n>``
267 number of lines of your screen. This is used to control
267 number of lines of your screen. This is used to control
268 printing of very long strings. Strings longer than this number
268 printing of very long strings. Strings longer than this number
269 of lines will be sent through a pager instead of directly
269 of lines will be sent through a pager instead of directly
270 printed.
270 printed.
271
271
272 The default value for this is 0, which means IPython will
272 The default value for this is 0, which means IPython will
273 auto-detect your screen size every time it needs to print certain
273 auto-detect your screen size every time it needs to print certain
274 potentially long strings (this doesn't change the behavior of the
274 potentially long strings (this doesn't change the behavior of the
275 'print' keyword, it's only triggered internally). If for some
275 'print' keyword, it's only triggered internally). If for some
276 reason this isn't working well (it needs curses support), specify
276 reason this isn't working well (it needs curses support), specify
277 it yourself. Otherwise don't change the default.
277 it yourself. Otherwise don't change the default.
278
278
279 ``TerminalInteractiveShell.separate_in=<string>``
279 ``--TerminalInteractiveShell.separate_in=<string>``
280
280
281 separator before input prompts.
281 separator before input prompts.
282 Default: '\n'
282 Default: '\n'
283
283
284 ``TerminalInteractiveShell.separate_out=<string>``
284 ``--TerminalInteractiveShell.separate_out=<string>``
285 separator before output prompts.
285 separator before output prompts.
286 Default: nothing.
286 Default: nothing.
287
287
288 ``TerminalInteractiveShell.separate_out2=<string>``
288 ``--TerminalInteractiveShell.separate_out2=<string>``
289 separator after output prompts.
289 separator after output prompts.
290 Default: nothing.
290 Default: nothing.
291 For these three options, use the value 0 to specify no separator.
291 For these three options, use the value 0 to specify no separator.
292
292
293 ``--nosep``
293 ``--nosep``
294 shorthand for setting the above separators to empty strings.
294 shorthand for setting the above separators to empty strings.
295
295
296 Simply removes all input/output separators.
296 Simply removes all input/output separators.
297
297
298 ``--init``
298 ``--init``
299 allows you to initialize a profile dir for configuration when you
299 allows you to initialize a profile dir for configuration when you
300 install a new version of IPython or want to use a new profile.
300 install a new version of IPython or want to use a new profile.
301 Since new versions may include new command line options or example
301 Since new versions may include new command line options or example
302 files, this copies updated config files. Note that you should probably
302 files, this copies updated config files. Note that you should probably
303 use %upgrade instead,it's a safer alternative.
303 use %upgrade instead,it's a safer alternative.
304
304
305 ``--version`` print version information and exit.
305 ``--version`` print version information and exit.
306
306
307 ``xmode=<modename>``
307 ``--xmode=<modename>``
308
308
309 Mode for exception reporting.
309 Mode for exception reporting.
310
310
311 Valid modes: Plain, Context and Verbose.
311 Valid modes: Plain, Context and Verbose.
312
312
313 * Plain: similar to python's normal traceback printing.
313 * Plain: similar to python's normal traceback printing.
314 * Context: prints 5 lines of context source code around each
314 * Context: prints 5 lines of context source code around each
315 line in the traceback.
315 line in the traceback.
316 * Verbose: similar to Context, but additionally prints the
316 * Verbose: similar to Context, but additionally prints the
317 variables currently visible where the exception happened
317 variables currently visible where the exception happened
318 (shortening their strings if too long). This can potentially be
318 (shortening their strings if too long). This can potentially be
319 very slow, if you happen to have a huge data structure whose
319 very slow, if you happen to have a huge data structure whose
320 string representation is complex to compute. Your computer may
320 string representation is complex to compute. Your computer may
321 appear to freeze for a while with cpu usage at 100%. If this
321 appear to freeze for a while with cpu usage at 100%. If this
322 occurs, you can cancel the traceback with Ctrl-C (maybe hitting it
322 occurs, you can cancel the traceback with Ctrl-C (maybe hitting it
323 more than once).
323 more than once).
324
324
325 Interactive use
325 Interactive use
326 ===============
326 ===============
327
327
328 IPython is meant to work as a drop-in
328 IPython is meant to work as a drop-in
329 replacement for the standard interactive interpreter. As such, any code
329 replacement for the standard interactive interpreter. As such, any code
330 which is valid python should execute normally under IPython (cases where
330 which is valid python should execute normally under IPython (cases where
331 this is not true should be reported as bugs). It does, however, offer
331 this is not true should be reported as bugs). It does, however, offer
332 many features which are not available at a standard python prompt. What
332 many features which are not available at a standard python prompt. What
333 follows is a list of these.
333 follows is a list of these.
334
334
335
335
336 Caution for Windows users
336 Caution for Windows users
337 -------------------------
337 -------------------------
338
338
339 Windows, unfortunately, uses the '\\' character as a path
339 Windows, unfortunately, uses the '\\' character as a path
340 separator. This is a terrible choice, because '\\' also represents the
340 separator. This is a terrible choice, because '\\' also represents the
341 escape character in most modern programming languages, including
341 escape character in most modern programming languages, including
342 Python. For this reason, using '/' character is recommended if you
342 Python. For this reason, using '/' character is recommended if you
343 have problems with ``\``. However, in Windows commands '/' flags
343 have problems with ``\``. However, in Windows commands '/' flags
344 options, so you can not use it for the root directory. This means that
344 options, so you can not use it for the root directory. This means that
345 paths beginning at the root must be typed in a contrived manner like:
345 paths beginning at the root must be typed in a contrived manner like:
346 ``%copy \opt/foo/bar.txt \tmp``
346 ``%copy \opt/foo/bar.txt \tmp``
347
347
348 .. _magic:
348 .. _magic:
349
349
350 Magic command system
350 Magic command system
351 --------------------
351 --------------------
352
352
353 IPython will treat any line whose first character is a % as a special
353 IPython will treat any line whose first character is a % as a special
354 call to a 'magic' function. These allow you to control the behavior of
354 call to a 'magic' function. These allow you to control the behavior of
355 IPython itself, plus a lot of system-type features. They are all
355 IPython itself, plus a lot of system-type features. They are all
356 prefixed with a % character, but parameters are given without
356 prefixed with a % character, but parameters are given without
357 parentheses or quotes.
357 parentheses or quotes.
358
358
359 Example: typing ``%cd mydir`` changes your working directory to 'mydir', if it
359 Example: typing ``%cd mydir`` changes your working directory to 'mydir', if it
360 exists.
360 exists.
361
361
362 If you have 'automagic' enabled (as it by default), you don't need
362 If you have 'automagic' enabled (as it by default), you don't need
363 to type in the % explicitly. IPython will scan its internal list of
363 to type in the % explicitly. IPython will scan its internal list of
364 magic functions and call one if it exists. With automagic on you can
364 magic functions and call one if it exists. With automagic on you can
365 then just type ``cd mydir`` to go to directory 'mydir'. The automagic
365 then just type ``cd mydir`` to go to directory 'mydir'. The automagic
366 system has the lowest possible precedence in name searches, so defining
366 system has the lowest possible precedence in name searches, so defining
367 an identifier with the same name as an existing magic function will
367 an identifier with the same name as an existing magic function will
368 shadow it for automagic use. You can still access the shadowed magic
368 shadow it for automagic use. You can still access the shadowed magic
369 function by explicitly using the % character at the beginning of the line.
369 function by explicitly using the % character at the beginning of the line.
370
370
371 An example (with automagic on) should clarify all this:
371 An example (with automagic on) should clarify all this:
372
372
373 .. sourcecode:: ipython
373 .. sourcecode:: ipython
374
374
375 In [1]: cd ipython # %cd is called by automagic
375 In [1]: cd ipython # %cd is called by automagic
376
376
377 /home/fperez/ipython
377 /home/fperez/ipython
378
378
379 In [2]: cd=1 # now cd is just a variable
379 In [2]: cd=1 # now cd is just a variable
380
380
381 In [3]: cd .. # and doesn't work as a function anymore
381 In [3]: cd .. # and doesn't work as a function anymore
382
382
383 ------------------------------
383 ------------------------------
384
384
385 File "<console>", line 1
385 File "<console>", line 1
386
386
387 cd ..
387 cd ..
388
388
389 ^
389 ^
390
390
391 SyntaxError: invalid syntax
391 SyntaxError: invalid syntax
392
392
393 In [4]: %cd .. # but %cd always works
393 In [4]: %cd .. # but %cd always works
394
394
395 /home/fperez
395 /home/fperez
396
396
397 In [5]: del cd # if you remove the cd variable
397 In [5]: del cd # if you remove the cd variable
398
398
399 In [6]: cd ipython # automagic can work again
399 In [6]: cd ipython # automagic can work again
400
400
401 /home/fperez/ipython
401 /home/fperez/ipython
402
402
403 You can define your own magic functions to extend the system. The
403 You can define your own magic functions to extend the system. The
404 following example defines a new magic command, %impall:
404 following example defines a new magic command, %impall:
405
405
406 .. sourcecode:: python
406 .. sourcecode:: python
407
407
408 ip = get_ipython()
408 ip = get_ipython()
409
409
410 def doimp(self, arg):
410 def doimp(self, arg):
411
411
412 ip = self.api
412 ip = self.api
413
413
414 ip.ex("import %s; reload(%s); from %s import *" % (
414 ip.ex("import %s; reload(%s); from %s import *" % (
415
415
416 arg,arg,arg)
416 arg,arg,arg)
417
417
418 )
418 )
419
419
420 ip.expose_magic('impall', doimp)
420 ip.expose_magic('impall', doimp)
421
421
422 Type %magic for more information, including a list of all available
422 Type %magic for more information, including a list of all available
423 magic functions at any time and their docstrings. You can also type
423 magic functions at any time and their docstrings. You can also type
424 %magic_function_name? (see sec. 6.4 <#sec:dyn-object-info> for
424 %magic_function_name? (see sec. 6.4 <#sec:dyn-object-info> for
425 information on the '?' system) to get information about any particular
425 information on the '?' system) to get information about any particular
426 magic function you are interested in.
426 magic function you are interested in.
427
427
428 The API documentation for the :mod:`IPython.core.magic` module contains the full
428 The API documentation for the :mod:`IPython.core.magic` module contains the full
429 docstrings of all currently available magic commands.
429 docstrings of all currently available magic commands.
430
430
431
431
432 Access to the standard Python help
432 Access to the standard Python help
433 ----------------------------------
433 ----------------------------------
434
434
435 As of Python 2.1, a help system is available with access to object docstrings
435 As of Python 2.1, a help system is available with access to object docstrings
436 and the Python manuals. Simply type 'help' (no quotes) to access it. You can
436 and the Python manuals. Simply type 'help' (no quotes) to access it. You can
437 also type help(object) to obtain information about a given object, and
437 also type help(object) to obtain information about a given object, and
438 help('keyword') for information on a keyword. As noted :ref:`here
438 help('keyword') for information on a keyword. As noted :ref:`here
439 <accessing_help>`, you need to properly configure your environment variable
439 <accessing_help>`, you need to properly configure your environment variable
440 PYTHONDOCS for this feature to work correctly.
440 PYTHONDOCS for this feature to work correctly.
441
441
442 .. _dynamic_object_info:
442 .. _dynamic_object_info:
443
443
444 Dynamic object information
444 Dynamic object information
445 --------------------------
445 --------------------------
446
446
447 Typing ?word or word? prints detailed information about an object. If
447 Typing ?word or word? prints detailed information about an object. If
448 certain strings in the object are too long (docstrings, code, etc.) they
448 certain strings in the object are too long (docstrings, code, etc.) they
449 get snipped in the center for brevity. This system gives access variable
449 get snipped in the center for brevity. This system gives access variable
450 types and values, full source code for any object (if available),
450 types and values, full source code for any object (if available),
451 function prototypes and other useful information.
451 function prototypes and other useful information.
452
452
453 Typing ??word or word?? gives access to the full information without
453 Typing ??word or word?? gives access to the full information without
454 snipping long strings. Long strings are sent to the screen through the
454 snipping long strings. Long strings are sent to the screen through the
455 less pager if longer than the screen and printed otherwise. On systems
455 less pager if longer than the screen and printed otherwise. On systems
456 lacking the less command, IPython uses a very basic internal pager.
456 lacking the less command, IPython uses a very basic internal pager.
457
457
458 The following magic functions are particularly useful for gathering
458 The following magic functions are particularly useful for gathering
459 information about your working environment. You can get more details by
459 information about your working environment. You can get more details by
460 typing %magic or querying them individually (use %function_name? with or
460 typing %magic or querying them individually (use %function_name? with or
461 without the %), this is just a summary:
461 without the %), this is just a summary:
462
462
463 * **%pdoc <object>**: Print (or run through a pager if too long) the
463 * **%pdoc <object>**: Print (or run through a pager if too long) the
464 docstring for an object. If the given object is a class, it will
464 docstring for an object. If the given object is a class, it will
465 print both the class and the constructor docstrings.
465 print both the class and the constructor docstrings.
466 * **%pdef <object>**: Print the definition header for any callable
466 * **%pdef <object>**: Print the definition header for any callable
467 object. If the object is a class, print the constructor information.
467 object. If the object is a class, print the constructor information.
468 * **%psource <object>**: Print (or run through a pager if too long)
468 * **%psource <object>**: Print (or run through a pager if too long)
469 the source code for an object.
469 the source code for an object.
470 * **%pfile <object>**: Show the entire source file where an object was
470 * **%pfile <object>**: Show the entire source file where an object was
471 defined via a pager, opening it at the line where the object
471 defined via a pager, opening it at the line where the object
472 definition begins.
472 definition begins.
473 * **%who/%whos**: These functions give information about identifiers
473 * **%who/%whos**: These functions give information about identifiers
474 you have defined interactively (not things you loaded or defined
474 you have defined interactively (not things you loaded or defined
475 in your configuration files). %who just prints a list of
475 in your configuration files). %who just prints a list of
476 identifiers and %whos prints a table with some basic details about
476 identifiers and %whos prints a table with some basic details about
477 each identifier.
477 each identifier.
478
478
479 Note that the dynamic object information functions (?/??, %pdoc, %pfile,
479 Note that the dynamic object information functions (?/??, %pdoc, %pfile,
480 %pdef, %psource) give you access to documentation even on things which
480 %pdef, %psource) give you access to documentation even on things which
481 are not really defined as separate identifiers. Try for example typing
481 are not really defined as separate identifiers. Try for example typing
482 {}.get? or after doing import os, type os.path.abspath??.
482 {}.get? or after doing import os, type os.path.abspath??.
483
483
484
484
485 .. _readline:
485 .. _readline:
486
486
487 Readline-based features
487 Readline-based features
488 -----------------------
488 -----------------------
489
489
490 These features require the GNU readline library, so they won't work if
490 These features require the GNU readline library, so they won't work if
491 your Python installation lacks readline support. We will first describe
491 your Python installation lacks readline support. We will first describe
492 the default behavior IPython uses, and then how to change it to suit
492 the default behavior IPython uses, and then how to change it to suit
493 your preferences.
493 your preferences.
494
494
495
495
496 Command line completion
496 Command line completion
497 +++++++++++++++++++++++
497 +++++++++++++++++++++++
498
498
499 At any time, hitting TAB will complete any available python commands or
499 At any time, hitting TAB will complete any available python commands or
500 variable names, and show you a list of the possible completions if
500 variable names, and show you a list of the possible completions if
501 there's no unambiguous one. It will also complete filenames in the
501 there's no unambiguous one. It will also complete filenames in the
502 current directory if no python names match what you've typed so far.
502 current directory if no python names match what you've typed so far.
503
503
504
504
505 Search command history
505 Search command history
506 ++++++++++++++++++++++
506 ++++++++++++++++++++++
507
507
508 IPython provides two ways for searching through previous input and thus
508 IPython provides two ways for searching through previous input and thus
509 reduce the need for repetitive typing:
509 reduce the need for repetitive typing:
510
510
511 1. Start typing, and then use Ctrl-p (previous,up) and Ctrl-n
511 1. Start typing, and then use Ctrl-p (previous,up) and Ctrl-n
512 (next,down) to search through only the history items that match
512 (next,down) to search through only the history items that match
513 what you've typed so far. If you use Ctrl-p/Ctrl-n at a blank
513 what you've typed so far. If you use Ctrl-p/Ctrl-n at a blank
514 prompt, they just behave like normal arrow keys.
514 prompt, they just behave like normal arrow keys.
515 2. Hit Ctrl-r: opens a search prompt. Begin typing and the system
515 2. Hit Ctrl-r: opens a search prompt. Begin typing and the system
516 searches your history for lines that contain what you've typed so
516 searches your history for lines that contain what you've typed so
517 far, completing as much as it can.
517 far, completing as much as it can.
518
518
519
519
520 Persistent command history across sessions
520 Persistent command history across sessions
521 ++++++++++++++++++++++++++++++++++++++++++
521 ++++++++++++++++++++++++++++++++++++++++++
522
522
523 IPython will save your input history when it leaves and reload it next
523 IPython will save your input history when it leaves and reload it next
524 time you restart it. By default, the history file is named
524 time you restart it. By default, the history file is named
525 $IPYTHON_DIR/profile_<name>/history.sqlite. This allows you to keep
525 $IPYTHON_DIR/profile_<name>/history.sqlite. This allows you to keep
526 separate histories related to various tasks: commands related to
526 separate histories related to various tasks: commands related to
527 numerical work will not be clobbered by a system shell history, for
527 numerical work will not be clobbered by a system shell history, for
528 example.
528 example.
529
529
530
530
531 Autoindent
531 Autoindent
532 ++++++++++
532 ++++++++++
533
533
534 IPython can recognize lines ending in ':' and indent the next line,
534 IPython can recognize lines ending in ':' and indent the next line,
535 while also un-indenting automatically after 'raise' or 'return'.
535 while also un-indenting automatically after 'raise' or 'return'.
536
536
537 This feature uses the readline library, so it will honor your ~/.inputrc
537 This feature uses the readline library, so it will honor your ~/.inputrc
538 configuration (or whatever file your INPUTRC variable points to). Adding
538 configuration (or whatever file your INPUTRC variable points to). Adding
539 the following lines to your .inputrc file can make indenting/unindenting
539 the following lines to your .inputrc file can make indenting/unindenting
540 more convenient (M-i indents, M-u unindents)::
540 more convenient (M-i indents, M-u unindents)::
541
541
542 $if Python
542 $if Python
543 "\M-i": " "
543 "\M-i": " "
544 "\M-u": "\d\d\d\d"
544 "\M-u": "\d\d\d\d"
545 $endif
545 $endif
546
546
547 Note that there are 4 spaces between the quote marks after "M-i" above.
547 Note that there are 4 spaces between the quote marks after "M-i" above.
548
548
549 .. warning::
549 .. warning::
550
550
551 Setting the above indents will cause problems with unicode text entry in the terminal.
551 Setting the above indents will cause problems with unicode text entry in the terminal.
552
552
553 .. warning::
553 .. warning::
554
554
555 Autoindent is ON by default, but it can cause problems with
555 Autoindent is ON by default, but it can cause problems with
556 the pasting of multi-line indented code (the pasted code gets
556 the pasting of multi-line indented code (the pasted code gets
557 re-indented on each line). A magic function %autoindent allows you to
557 re-indented on each line). A magic function %autoindent allows you to
558 toggle it on/off at runtime. You can also disable it permanently on in
558 toggle it on/off at runtime. You can also disable it permanently on in
559 your :file:`ipython_config.py` file (set TerminalInteractiveShell.autoindent=False).
559 your :file:`ipython_config.py` file (set TerminalInteractiveShell.autoindent=False).
560
560
561 If you want to paste multiple lines, it is recommended that you use ``%paste``.
561 If you want to paste multiple lines, it is recommended that you use ``%paste``.
562
562
563
563
564 Customizing readline behavior
564 Customizing readline behavior
565 +++++++++++++++++++++++++++++
565 +++++++++++++++++++++++++++++
566
566
567 All these features are based on the GNU readline library, which has an
567 All these features are based on the GNU readline library, which has an
568 extremely customizable interface. Normally, readline is configured via a
568 extremely customizable interface. Normally, readline is configured via a
569 file which defines the behavior of the library; the details of the
569 file which defines the behavior of the library; the details of the
570 syntax for this can be found in the readline documentation available
570 syntax for this can be found in the readline documentation available
571 with your system or on the Internet. IPython doesn't read this file (if
571 with your system or on the Internet. IPython doesn't read this file (if
572 it exists) directly, but it does support passing to readline valid
572 it exists) directly, but it does support passing to readline valid
573 options via a simple interface. In brief, you can customize readline by
573 options via a simple interface. In brief, you can customize readline by
574 setting the following options in your ipythonrc configuration file (note
574 setting the following options in your ipythonrc configuration file (note
575 that these options can not be specified at the command line):
575 that these options can not be specified at the command line):
576
576
577 * **readline_parse_and_bind**: this option can appear as many times as
577 * **readline_parse_and_bind**: this option can appear as many times as
578 you want, each time defining a string to be executed via a
578 you want, each time defining a string to be executed via a
579 readline.parse_and_bind() command. The syntax for valid commands
579 readline.parse_and_bind() command. The syntax for valid commands
580 of this kind can be found by reading the documentation for the GNU
580 of this kind can be found by reading the documentation for the GNU
581 readline library, as these commands are of the kind which readline
581 readline library, as these commands are of the kind which readline
582 accepts in its configuration file.
582 accepts in its configuration file.
583 * **readline_remove_delims**: a string of characters to be removed
583 * **readline_remove_delims**: a string of characters to be removed
584 from the default word-delimiters list used by readline, so that
584 from the default word-delimiters list used by readline, so that
585 completions may be performed on strings which contain them. Do not
585 completions may be performed on strings which contain them. Do not
586 change the default value unless you know what you're doing.
586 change the default value unless you know what you're doing.
587 * **readline_omit__names**: when tab-completion is enabled, hitting
587 * **readline_omit__names**: when tab-completion is enabled, hitting
588 <tab> after a '.' in a name will complete all attributes of an
588 <tab> after a '.' in a name will complete all attributes of an
589 object, including all the special methods whose names include
589 object, including all the special methods whose names include
590 double underscores (like __getitem__ or __class__). If you'd
590 double underscores (like __getitem__ or __class__). If you'd
591 rather not see these names by default, you can set this option to
591 rather not see these names by default, you can set this option to
592 1. Note that even when this option is set, you can still see those
592 1. Note that even when this option is set, you can still see those
593 names by explicitly typing a _ after the period and hitting <tab>:
593 names by explicitly typing a _ after the period and hitting <tab>:
594 'name._<tab>' will always complete attribute names starting with '_'.
594 'name._<tab>' will always complete attribute names starting with '_'.
595
595
596 This option is off by default so that new users see all
596 This option is off by default so that new users see all
597 attributes of any objects they are dealing with.
597 attributes of any objects they are dealing with.
598
598
599 You will find the default values along with a corresponding detailed
599 You will find the default values along with a corresponding detailed
600 explanation in your ipythonrc file.
600 explanation in your ipythonrc file.
601
601
602
602
603 Session logging and restoring
603 Session logging and restoring
604 -----------------------------
604 -----------------------------
605
605
606 You can log all input from a session either by starting IPython with the
606 You can log all input from a session either by starting IPython with the
607 command line switche ``logfile=foo.py`` (see :ref:`here <command_line_options>`)
607 command line switche ``logfile=foo.py`` (see :ref:`here <command_line_options>`)
608 or by activating the logging at any moment with the magic function %logstart.
608 or by activating the logging at any moment with the magic function %logstart.
609
609
610 Log files can later be reloaded by running them as scripts and IPython
610 Log files can later be reloaded by running them as scripts and IPython
611 will attempt to 'replay' the log by executing all the lines in it, thus
611 will attempt to 'replay' the log by executing all the lines in it, thus
612 restoring the state of a previous session. This feature is not quite
612 restoring the state of a previous session. This feature is not quite
613 perfect, but can still be useful in many cases.
613 perfect, but can still be useful in many cases.
614
614
615 The log files can also be used as a way to have a permanent record of
615 The log files can also be used as a way to have a permanent record of
616 any code you wrote while experimenting. Log files are regular text files
616 any code you wrote while experimenting. Log files are regular text files
617 which you can later open in your favorite text editor to extract code or
617 which you can later open in your favorite text editor to extract code or
618 to 'clean them up' before using them to replay a session.
618 to 'clean them up' before using them to replay a session.
619
619
620 The %logstart function for activating logging in mid-session is used as
620 The %logstart function for activating logging in mid-session is used as
621 follows:
621 follows:
622
622
623 %logstart [log_name [log_mode]]
623 %logstart [log_name [log_mode]]
624
624
625 If no name is given, it defaults to a file named 'ipython_log.py' in your
625 If no name is given, it defaults to a file named 'ipython_log.py' in your
626 current working directory, in 'rotate' mode (see below).
626 current working directory, in 'rotate' mode (see below).
627
627
628 '%logstart name' saves to file 'name' in 'backup' mode. It saves your
628 '%logstart name' saves to file 'name' in 'backup' mode. It saves your
629 history up to that point and then continues logging.
629 history up to that point and then continues logging.
630
630
631 %logstart takes a second optional parameter: logging mode. This can be
631 %logstart takes a second optional parameter: logging mode. This can be
632 one of (note that the modes are given unquoted):
632 one of (note that the modes are given unquoted):
633
633
634 * [over:] overwrite existing log_name.
634 * [over:] overwrite existing log_name.
635 * [backup:] rename (if exists) to log_name~ and start log_name.
635 * [backup:] rename (if exists) to log_name~ and start log_name.
636 * [append:] well, that says it.
636 * [append:] well, that says it.
637 * [rotate:] create rotating logs log_name.1~, log_name.2~, etc.
637 * [rotate:] create rotating logs log_name.1~, log_name.2~, etc.
638
638
639 The %logoff and %logon functions allow you to temporarily stop and
639 The %logoff and %logon functions allow you to temporarily stop and
640 resume logging to a file which had previously been started with
640 resume logging to a file which had previously been started with
641 %logstart. They will fail (with an explanation) if you try to use them
641 %logstart. They will fail (with an explanation) if you try to use them
642 before logging has been started.
642 before logging has been started.
643
643
644 .. _system_shell_access:
644 .. _system_shell_access:
645
645
646 System shell access
646 System shell access
647 -------------------
647 -------------------
648
648
649 Any input line beginning with a ! character is passed verbatim (minus
649 Any input line beginning with a ! character is passed verbatim (minus
650 the !, of course) to the underlying operating system. For example,
650 the !, of course) to the underlying operating system. For example,
651 typing !ls will run 'ls' in the current directory.
651 typing !ls will run 'ls' in the current directory.
652
652
653 Manual capture of command output
653 Manual capture of command output
654 --------------------------------
654 --------------------------------
655
655
656 If the input line begins with two exclamation marks, !!, the command is
656 If the input line begins with two exclamation marks, !!, the command is
657 executed but its output is captured and returned as a python list, split
657 executed but its output is captured and returned as a python list, split
658 on newlines. Any output sent by the subprocess to standard error is
658 on newlines. Any output sent by the subprocess to standard error is
659 printed separately, so that the resulting list only captures standard
659 printed separately, so that the resulting list only captures standard
660 output. The !! syntax is a shorthand for the %sx magic command.
660 output. The !! syntax is a shorthand for the %sx magic command.
661
661
662 Finally, the %sc magic (short for 'shell capture') is similar to %sx,
662 Finally, the %sc magic (short for 'shell capture') is similar to %sx,
663 but allowing more fine-grained control of the capture details, and
663 but allowing more fine-grained control of the capture details, and
664 storing the result directly into a named variable. The direct use of
664 storing the result directly into a named variable. The direct use of
665 %sc is now deprecated, and you should ise the ``var = !cmd`` syntax
665 %sc is now deprecated, and you should ise the ``var = !cmd`` syntax
666 instead.
666 instead.
667
667
668 IPython also allows you to expand the value of python variables when
668 IPython also allows you to expand the value of python variables when
669 making system calls. Any python variable or expression which you prepend
669 making system calls. Any python variable or expression which you prepend
670 with $ will get expanded before the system call is made::
670 with $ will get expanded before the system call is made::
671
671
672 In [1]: pyvar='Hello world'
672 In [1]: pyvar='Hello world'
673 In [2]: !echo "A python variable: $pyvar"
673 In [2]: !echo "A python variable: $pyvar"
674 A python variable: Hello world
674 A python variable: Hello world
675
675
676 If you want the shell to actually see a literal $, you need to type it
676 If you want the shell to actually see a literal $, you need to type it
677 twice::
677 twice::
678
678
679 In [3]: !echo "A system variable: $$HOME"
679 In [3]: !echo "A system variable: $$HOME"
680 A system variable: /home/fperez
680 A system variable: /home/fperez
681
681
682 You can pass arbitrary expressions, though you'll need to delimit them
682 You can pass arbitrary expressions, though you'll need to delimit them
683 with {} if there is ambiguity as to the extent of the expression::
683 with {} if there is ambiguity as to the extent of the expression::
684
684
685 In [5]: x=10
685 In [5]: x=10
686 In [6]: y=20
686 In [6]: y=20
687 In [13]: !echo $x+y
687 In [13]: !echo $x+y
688 10+y
688 10+y
689 In [7]: !echo ${x+y}
689 In [7]: !echo ${x+y}
690 30
690 30
691
691
692 Even object attributes can be expanded::
692 Even object attributes can be expanded::
693
693
694 In [12]: !echo $sys.argv
694 In [12]: !echo $sys.argv
695 [/home/fperez/usr/bin/ipython]
695 [/home/fperez/usr/bin/ipython]
696
696
697
697
698 System command aliases
698 System command aliases
699 ----------------------
699 ----------------------
700
700
701 The %alias magic function and the alias option in the ipythonrc
701 The %alias magic function and the alias option in the ipythonrc
702 configuration file allow you to define magic functions which are in fact
702 configuration file allow you to define magic functions which are in fact
703 system shell commands. These aliases can have parameters.
703 system shell commands. These aliases can have parameters.
704
704
705 '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
705 '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
706
706
707 Then, typing '%alias_name params' will execute the system command 'cmd
707 Then, typing '%alias_name params' will execute the system command 'cmd
708 params' (from your underlying operating system).
708 params' (from your underlying operating system).
709
709
710 You can also define aliases with parameters using %s specifiers (one per
710 You can also define aliases with parameters using %s specifiers (one per
711 parameter). The following example defines the %parts function as an
711 parameter). The following example defines the %parts function as an
712 alias to the command 'echo first %s second %s' where each %s will be
712 alias to the command 'echo first %s second %s' where each %s will be
713 replaced by a positional parameter to the call to %parts::
713 replaced by a positional parameter to the call to %parts::
714
714
715 In [1]: alias parts echo first %s second %s
715 In [1]: alias parts echo first %s second %s
716 In [2]: %parts A B
716 In [2]: %parts A B
717 first A second B
717 first A second B
718 In [3]: %parts A
718 In [3]: %parts A
719 Incorrect number of arguments: 2 expected.
719 Incorrect number of arguments: 2 expected.
720 parts is an alias to: 'echo first %s second %s'
720 parts is an alias to: 'echo first %s second %s'
721
721
722 If called with no parameters, %alias prints the table of currently
722 If called with no parameters, %alias prints the table of currently
723 defined aliases.
723 defined aliases.
724
724
725 The %rehash/rehashx magics allow you to load your entire $PATH as
725 The %rehash/rehashx magics allow you to load your entire $PATH as
726 ipython aliases. See their respective docstrings (or sec. 6.2
726 ipython aliases. See their respective docstrings (or sec. 6.2
727 <#sec:magic> for further details).
727 <#sec:magic> for further details).
728
728
729
729
730 .. _dreload:
730 .. _dreload:
731
731
732 Recursive reload
732 Recursive reload
733 ----------------
733 ----------------
734
734
735 The dreload function does a recursive reload of a module: changes made
735 The dreload function does a recursive reload of a module: changes made
736 to the module since you imported will actually be available without
736 to the module since you imported will actually be available without
737 having to exit.
737 having to exit.
738
738
739
739
740 Verbose and colored exception traceback printouts
740 Verbose and colored exception traceback printouts
741 -------------------------------------------------
741 -------------------------------------------------
742
742
743 IPython provides the option to see very detailed exception tracebacks,
743 IPython provides the option to see very detailed exception tracebacks,
744 which can be especially useful when debugging large programs. You can
744 which can be especially useful when debugging large programs. You can
745 run any Python file with the %run function to benefit from these
745 run any Python file with the %run function to benefit from these
746 detailed tracebacks. Furthermore, both normal and verbose tracebacks can
746 detailed tracebacks. Furthermore, both normal and verbose tracebacks can
747 be colored (if your terminal supports it) which makes them much easier
747 be colored (if your terminal supports it) which makes them much easier
748 to parse visually.
748 to parse visually.
749
749
750 See the magic xmode and colors functions for details (just type %magic).
750 See the magic xmode and colors functions for details (just type %magic).
751
751
752 These features are basically a terminal version of Ka-Ping Yee's cgitb
752 These features are basically a terminal version of Ka-Ping Yee's cgitb
753 module, now part of the standard Python library.
753 module, now part of the standard Python library.
754
754
755
755
756 .. _input_caching:
756 .. _input_caching:
757
757
758 Input caching system
758 Input caching system
759 --------------------
759 --------------------
760
760
761 IPython offers numbered prompts (In/Out) with input and output caching
761 IPython offers numbered prompts (In/Out) with input and output caching
762 (also referred to as 'input history'). All input is saved and can be
762 (also referred to as 'input history'). All input is saved and can be
763 retrieved as variables (besides the usual arrow key recall), in
763 retrieved as variables (besides the usual arrow key recall), in
764 addition to the %rep magic command that brings a history entry
764 addition to the %rep magic command that brings a history entry
765 up for editing on the next command line.
765 up for editing on the next command line.
766
766
767 The following GLOBAL variables always exist (so don't overwrite them!):
767 The following GLOBAL variables always exist (so don't overwrite them!):
768 _i: stores previous input. _ii: next previous. _iii: next-next previous.
768 _i: stores previous input. _ii: next previous. _iii: next-next previous.
769 _ih : a list of all input _ih[n] is the input from line n and this list
769 _ih : a list of all input _ih[n] is the input from line n and this list
770 is aliased to the global variable In. If you overwrite In with a
770 is aliased to the global variable In. If you overwrite In with a
771 variable of your own, you can remake the assignment to the internal list
771 variable of your own, you can remake the assignment to the internal list
772 with a simple 'In=_ih'.
772 with a simple 'In=_ih'.
773
773
774 Additionally, global variables named _i<n> are dynamically created (<n>
774 Additionally, global variables named _i<n> are dynamically created (<n>
775 being the prompt counter), such that
775 being the prompt counter), such that
776 _i<n> == _ih[<n>] == In[<n>].
776 _i<n> == _ih[<n>] == In[<n>].
777
777
778 For example, what you typed at prompt 14 is available as _i14, _ih[14]
778 For example, what you typed at prompt 14 is available as _i14, _ih[14]
779 and In[14].
779 and In[14].
780
780
781 This allows you to easily cut and paste multi line interactive prompts
781 This allows you to easily cut and paste multi line interactive prompts
782 by printing them out: they print like a clean string, without prompt
782 by printing them out: they print like a clean string, without prompt
783 characters. You can also manipulate them like regular variables (they
783 characters. You can also manipulate them like regular variables (they
784 are strings), modify or exec them (typing 'exec _i9' will re-execute the
784 are strings), modify or exec them (typing 'exec _i9' will re-execute the
785 contents of input prompt 9, 'exec In[9:14]+In[18]' will re-execute lines
785 contents of input prompt 9, 'exec In[9:14]+In[18]' will re-execute lines
786 9 through 13 and line 18).
786 9 through 13 and line 18).
787
787
788 You can also re-execute multiple lines of input easily by using the
788 You can also re-execute multiple lines of input easily by using the
789 magic %macro function (which automates the process and allows
789 magic %macro function (which automates the process and allows
790 re-execution without having to type 'exec' every time). The macro system
790 re-execution without having to type 'exec' every time). The macro system
791 also allows you to re-execute previous lines which include magic
791 also allows you to re-execute previous lines which include magic
792 function calls (which require special processing). Type %macro? or see
792 function calls (which require special processing). Type %macro? or see
793 sec. 6.2 <#sec:magic> for more details on the macro system.
793 sec. 6.2 <#sec:magic> for more details on the macro system.
794
794
795 A history function %hist allows you to see any part of your input
795 A history function %hist allows you to see any part of your input
796 history by printing a range of the _i variables.
796 history by printing a range of the _i variables.
797
797
798 You can also search ('grep') through your history by typing
798 You can also search ('grep') through your history by typing
799 '%hist -g somestring'. This also searches through the so called *shadow history*,
799 '%hist -g somestring'. This also searches through the so called *shadow history*,
800 which remembers all the commands (apart from multiline code blocks)
800 which remembers all the commands (apart from multiline code blocks)
801 you have ever entered. Handy for searching for svn/bzr URL's, IP adrresses
801 you have ever entered. Handy for searching for svn/bzr URL's, IP adrresses
802 etc. You can bring shadow history entries listed by '%hist -g' up for editing
802 etc. You can bring shadow history entries listed by '%hist -g' up for editing
803 (or re-execution by just pressing ENTER) with %rep command. Shadow history
803 (or re-execution by just pressing ENTER) with %rep command. Shadow history
804 entries are not available as _iNUMBER variables, and they are identified by
804 entries are not available as _iNUMBER variables, and they are identified by
805 the '0' prefix in %hist -g output. That is, history entry 12 is a normal
805 the '0' prefix in %hist -g output. That is, history entry 12 is a normal
806 history entry, but 0231 is a shadow history entry.
806 history entry, but 0231 is a shadow history entry.
807
807
808 Shadow history was added because the readline history is inherently very
808 Shadow history was added because the readline history is inherently very
809 unsafe - if you have multiple IPython sessions open, the last session
809 unsafe - if you have multiple IPython sessions open, the last session
810 to close will overwrite the history of previountly closed session. Likewise,
810 to close will overwrite the history of previountly closed session. Likewise,
811 if a crash occurs, history is never saved, whereas shadow history entries
811 if a crash occurs, history is never saved, whereas shadow history entries
812 are added after entering every command (so a command executed
812 are added after entering every command (so a command executed
813 in another IPython session is immediately available in other IPython
813 in another IPython session is immediately available in other IPython
814 sessions that are open).
814 sessions that are open).
815
815
816 To conserve space, a command can exist in shadow history only once - it doesn't
816 To conserve space, a command can exist in shadow history only once - it doesn't
817 make sense to store a common line like "cd .." a thousand times. The idea is
817 make sense to store a common line like "cd .." a thousand times. The idea is
818 mainly to provide a reliable place where valuable, hard-to-remember commands can
818 mainly to provide a reliable place where valuable, hard-to-remember commands can
819 always be retrieved, as opposed to providing an exact sequence of commands
819 always be retrieved, as opposed to providing an exact sequence of commands
820 you have entered in actual order.
820 you have entered in actual order.
821
821
822 Because shadow history has all the commands you have ever executed,
822 Because shadow history has all the commands you have ever executed,
823 time taken by %hist -g will increase oven time. If it ever starts to take
823 time taken by %hist -g will increase oven time. If it ever starts to take
824 too long (or it ends up containing sensitive information like passwords),
824 too long (or it ends up containing sensitive information like passwords),
825 clear the shadow history by `%clear shadow_nuke`.
825 clear the shadow history by `%clear shadow_nuke`.
826
826
827 Time taken to add entries to shadow history should be negligible, but
827 Time taken to add entries to shadow history should be negligible, but
828 in any case, if you start noticing performance degradation after using
828 in any case, if you start noticing performance degradation after using
829 IPython for a long time (or running a script that floods the shadow history!),
829 IPython for a long time (or running a script that floods the shadow history!),
830 you can 'compress' the shadow history by executing
830 you can 'compress' the shadow history by executing
831 `%clear shadow_compress`. In practice, this should never be necessary
831 `%clear shadow_compress`. In practice, this should never be necessary
832 in normal use.
832 in normal use.
833
833
834 .. _output_caching:
834 .. _output_caching:
835
835
836 Output caching system
836 Output caching system
837 ---------------------
837 ---------------------
838
838
839 For output that is returned from actions, a system similar to the input
839 For output that is returned from actions, a system similar to the input
840 cache exists but using _ instead of _i. Only actions that produce a
840 cache exists but using _ instead of _i. Only actions that produce a
841 result (NOT assignments, for example) are cached. If you are familiar
841 result (NOT assignments, for example) are cached. If you are familiar
842 with Mathematica, IPython's _ variables behave exactly like
842 with Mathematica, IPython's _ variables behave exactly like
843 Mathematica's % variables.
843 Mathematica's % variables.
844
844
845 The following GLOBAL variables always exist (so don't overwrite them!):
845 The following GLOBAL variables always exist (so don't overwrite them!):
846
846
847 * [_] (a single underscore) : stores previous output, like Python's
847 * [_] (a single underscore) : stores previous output, like Python's
848 default interpreter.
848 default interpreter.
849 * [__] (two underscores): next previous.
849 * [__] (two underscores): next previous.
850 * [___] (three underscores): next-next previous.
850 * [___] (three underscores): next-next previous.
851
851
852 Additionally, global variables named _<n> are dynamically created (<n>
852 Additionally, global variables named _<n> are dynamically created (<n>
853 being the prompt counter), such that the result of output <n> is always
853 being the prompt counter), such that the result of output <n> is always
854 available as _<n> (don't use the angle brackets, just the number, e.g.
854 available as _<n> (don't use the angle brackets, just the number, e.g.
855 _21).
855 _21).
856
856
857 These global variables are all stored in a global dictionary (not a
857 These global variables are all stored in a global dictionary (not a
858 list, since it only has entries for lines which returned a result)
858 list, since it only has entries for lines which returned a result)
859 available under the names _oh and Out (similar to _ih and In). So the
859 available under the names _oh and Out (similar to _ih and In). So the
860 output from line 12 can be obtained as _12, Out[12] or _oh[12]. If you
860 output from line 12 can be obtained as _12, Out[12] or _oh[12]. If you
861 accidentally overwrite the Out variable you can recover it by typing
861 accidentally overwrite the Out variable you can recover it by typing
862 'Out=_oh' at the prompt.
862 'Out=_oh' at the prompt.
863
863
864 This system obviously can potentially put heavy memory demands on your
864 This system obviously can potentially put heavy memory demands on your
865 system, since it prevents Python's garbage collector from removing any
865 system, since it prevents Python's garbage collector from removing any
866 previously computed results. You can control how many results are kept
866 previously computed results. You can control how many results are kept
867 in memory with the option (at the command line or in your ipythonrc
867 in memory with the option (at the command line or in your ipythonrc
868 file) cache_size. If you set it to 0, the whole system is completely
868 file) cache_size. If you set it to 0, the whole system is completely
869 disabled and the prompts revert to the classic '>>>' of normal Python.
869 disabled and the prompts revert to the classic '>>>' of normal Python.
870
870
871
871
872 Directory history
872 Directory history
873 -----------------
873 -----------------
874
874
875 Your history of visited directories is kept in the global list _dh, and
875 Your history of visited directories is kept in the global list _dh, and
876 the magic %cd command can be used to go to any entry in that list. The
876 the magic %cd command can be used to go to any entry in that list. The
877 %dhist command allows you to view this history. Do ``cd -<TAB`` to
877 %dhist command allows you to view this history. Do ``cd -<TAB`` to
878 conveniently view the directory history.
878 conveniently view the directory history.
879
879
880
880
881 Automatic parentheses and quotes
881 Automatic parentheses and quotes
882 --------------------------------
882 --------------------------------
883
883
884 These features were adapted from Nathan Gray's LazyPython. They are
884 These features were adapted from Nathan Gray's LazyPython. They are
885 meant to allow less typing for common situations.
885 meant to allow less typing for common situations.
886
886
887
887
888 Automatic parentheses
888 Automatic parentheses
889 ---------------------
889 ---------------------
890
890
891 Callable objects (i.e. functions, methods, etc) can be invoked like this
891 Callable objects (i.e. functions, methods, etc) can be invoked like this
892 (notice the commas between the arguments)::
892 (notice the commas between the arguments)::
893
893
894 >>> callable_ob arg1, arg2, arg3
894 >>> callable_ob arg1, arg2, arg3
895
895
896 and the input will be translated to this::
896 and the input will be translated to this::
897
897
898 -> callable_ob(arg1, arg2, arg3)
898 -> callable_ob(arg1, arg2, arg3)
899
899
900 You can force automatic parentheses by using '/' as the first character
900 You can force automatic parentheses by using '/' as the first character
901 of a line. For example::
901 of a line. For example::
902
902
903 >>> /globals # becomes 'globals()'
903 >>> /globals # becomes 'globals()'
904
904
905 Note that the '/' MUST be the first character on the line! This won't work::
905 Note that the '/' MUST be the first character on the line! This won't work::
906
906
907 >>> print /globals # syntax error
907 >>> print /globals # syntax error
908
908
909 In most cases the automatic algorithm should work, so you should rarely
909 In most cases the automatic algorithm should work, so you should rarely
910 need to explicitly invoke /. One notable exception is if you are trying
910 need to explicitly invoke /. One notable exception is if you are trying
911 to call a function with a list of tuples as arguments (the parenthesis
911 to call a function with a list of tuples as arguments (the parenthesis
912 will confuse IPython)::
912 will confuse IPython)::
913
913
914 In [1]: zip (1,2,3),(4,5,6) # won't work
914 In [1]: zip (1,2,3),(4,5,6) # won't work
915
915
916 but this will work::
916 but this will work::
917
917
918 In [2]: /zip (1,2,3),(4,5,6)
918 In [2]: /zip (1,2,3),(4,5,6)
919 ---> zip ((1,2,3),(4,5,6))
919 ---> zip ((1,2,3),(4,5,6))
920 Out[2]= [(1, 4), (2, 5), (3, 6)]
920 Out[2]= [(1, 4), (2, 5), (3, 6)]
921
921
922 IPython tells you that it has altered your command line by displaying
922 IPython tells you that it has altered your command line by displaying
923 the new command line preceded by ->. e.g.::
923 the new command line preceded by ->. e.g.::
924
924
925 In [18]: callable list
925 In [18]: callable list
926 ----> callable (list)
926 ----> callable (list)
927
927
928
928
929 Automatic quoting
929 Automatic quoting
930 -----------------
930 -----------------
931
931
932 You can force automatic quoting of a function's arguments by using ','
932 You can force automatic quoting of a function's arguments by using ','
933 or ';' as the first character of a line. For example::
933 or ';' as the first character of a line. For example::
934
934
935 >>> ,my_function /home/me # becomes my_function("/home/me")
935 >>> ,my_function /home/me # becomes my_function("/home/me")
936
936
937 If you use ';' instead, the whole argument is quoted as a single string
937 If you use ';' instead, the whole argument is quoted as a single string
938 (while ',' splits on whitespace)::
938 (while ',' splits on whitespace)::
939
939
940 >>> ,my_function a b c # becomes my_function("a","b","c")
940 >>> ,my_function a b c # becomes my_function("a","b","c")
941
941
942 >>> ;my_function a b c # becomes my_function("a b c")
942 >>> ;my_function a b c # becomes my_function("a b c")
943
943
944 Note that the ',' or ';' MUST be the first character on the line! This
944 Note that the ',' or ';' MUST be the first character on the line! This
945 won't work::
945 won't work::
946
946
947 >>> x = ,my_function /home/me # syntax error
947 >>> x = ,my_function /home/me # syntax error
948
948
949 IPython as your default Python environment
949 IPython as your default Python environment
950 ==========================================
950 ==========================================
951
951
952 Python honors the environment variable PYTHONSTARTUP and will execute at
952 Python honors the environment variable PYTHONSTARTUP and will execute at
953 startup the file referenced by this variable. If you put at the end of
953 startup the file referenced by this variable. If you put at the end of
954 this file the following two lines of code::
954 this file the following two lines of code::
955
955
956 from IPython.frontend.terminal.ipapp import launch_new_instance
956 from IPython.frontend.terminal.ipapp import launch_new_instance
957 launch_new_instance()
957 launch_new_instance()
958 raise SystemExit
958 raise SystemExit
959
959
960 then IPython will be your working environment anytime you start Python.
960 then IPython will be your working environment anytime you start Python.
961 The ``raise SystemExit`` is needed to exit Python when
961 The ``raise SystemExit`` is needed to exit Python when
962 it finishes, otherwise you'll be back at the normal Python '>>>'
962 it finishes, otherwise you'll be back at the normal Python '>>>'
963 prompt.
963 prompt.
964
964
965 This is probably useful to developers who manage multiple Python
965 This is probably useful to developers who manage multiple Python
966 versions and don't want to have correspondingly multiple IPython
966 versions and don't want to have correspondingly multiple IPython
967 versions. Note that in this mode, there is no way to pass IPython any
967 versions. Note that in this mode, there is no way to pass IPython any
968 command-line options, as those are trapped first by Python itself.
968 command-line options, as those are trapped first by Python itself.
969
969
970 .. _Embedding:
970 .. _Embedding:
971
971
972 Embedding IPython
972 Embedding IPython
973 =================
973 =================
974
974
975 It is possible to start an IPython instance inside your own Python
975 It is possible to start an IPython instance inside your own Python
976 programs. This allows you to evaluate dynamically the state of your
976 programs. This allows you to evaluate dynamically the state of your
977 code, operate with your variables, analyze them, etc. Note however that
977 code, operate with your variables, analyze them, etc. Note however that
978 any changes you make to values while in the shell do not propagate back
978 any changes you make to values while in the shell do not propagate back
979 to the running code, so it is safe to modify your values because you
979 to the running code, so it is safe to modify your values because you
980 won't break your code in bizarre ways by doing so.
980 won't break your code in bizarre ways by doing so.
981
981
982 This feature allows you to easily have a fully functional python
982 This feature allows you to easily have a fully functional python
983 environment for doing object introspection anywhere in your code with a
983 environment for doing object introspection anywhere in your code with a
984 simple function call. In some cases a simple print statement is enough,
984 simple function call. In some cases a simple print statement is enough,
985 but if you need to do more detailed analysis of a code fragment this
985 but if you need to do more detailed analysis of a code fragment this
986 feature can be very valuable.
986 feature can be very valuable.
987
987
988 It can also be useful in scientific computing situations where it is
988 It can also be useful in scientific computing situations where it is
989 common to need to do some automatic, computationally intensive part and
989 common to need to do some automatic, computationally intensive part and
990 then stop to look at data, plots, etc.
990 then stop to look at data, plots, etc.
991 Opening an IPython instance will give you full access to your data and
991 Opening an IPython instance will give you full access to your data and
992 functions, and you can resume program execution once you are done with
992 functions, and you can resume program execution once you are done with
993 the interactive part (perhaps to stop again later, as many times as
993 the interactive part (perhaps to stop again later, as many times as
994 needed).
994 needed).
995
995
996 The following code snippet is the bare minimum you need to include in
996 The following code snippet is the bare minimum you need to include in
997 your Python programs for this to work (detailed examples follow later)::
997 your Python programs for this to work (detailed examples follow later)::
998
998
999 from IPython import embed
999 from IPython import embed
1000
1000
1001 embed() # this call anywhere in your program will start IPython
1001 embed() # this call anywhere in your program will start IPython
1002
1002
1003 You can run embedded instances even in code which is itself being run at
1003 You can run embedded instances even in code which is itself being run at
1004 the IPython interactive prompt with '%run <filename>'. Since it's easy
1004 the IPython interactive prompt with '%run <filename>'. Since it's easy
1005 to get lost as to where you are (in your top-level IPython or in your
1005 to get lost as to where you are (in your top-level IPython or in your
1006 embedded one), it's a good idea in such cases to set the in/out prompts
1006 embedded one), it's a good idea in such cases to set the in/out prompts
1007 to something different for the embedded instances. The code examples
1007 to something different for the embedded instances. The code examples
1008 below illustrate this.
1008 below illustrate this.
1009
1009
1010 You can also have multiple IPython instances in your program and open
1010 You can also have multiple IPython instances in your program and open
1011 them separately, for example with different options for data
1011 them separately, for example with different options for data
1012 presentation. If you close and open the same instance multiple times,
1012 presentation. If you close and open the same instance multiple times,
1013 its prompt counters simply continue from each execution to the next.
1013 its prompt counters simply continue from each execution to the next.
1014
1014
1015 Please look at the docstrings in the :mod:`~IPython.frontend.terminal.embed`
1015 Please look at the docstrings in the :mod:`~IPython.frontend.terminal.embed`
1016 module for more details on the use of this system.
1016 module for more details on the use of this system.
1017
1017
1018 The following sample file illustrating how to use the embedding
1018 The following sample file illustrating how to use the embedding
1019 functionality is provided in the examples directory as example-embed.py.
1019 functionality is provided in the examples directory as example-embed.py.
1020 It should be fairly self-explanatory:
1020 It should be fairly self-explanatory:
1021
1021
1022 .. literalinclude:: ../../examples/core/example-embed.py
1022 .. literalinclude:: ../../examples/core/example-embed.py
1023 :language: python
1023 :language: python
1024
1024
1025 Once you understand how the system functions, you can use the following
1025 Once you understand how the system functions, you can use the following
1026 code fragments in your programs which are ready for cut and paste:
1026 code fragments in your programs which are ready for cut and paste:
1027
1027
1028 .. literalinclude:: ../../examples/core/example-embed-short.py
1028 .. literalinclude:: ../../examples/core/example-embed-short.py
1029 :language: python
1029 :language: python
1030
1030
1031 Using the Python debugger (pdb)
1031 Using the Python debugger (pdb)
1032 ===============================
1032 ===============================
1033
1033
1034 Running entire programs via pdb
1034 Running entire programs via pdb
1035 -------------------------------
1035 -------------------------------
1036
1036
1037 pdb, the Python debugger, is a powerful interactive debugger which
1037 pdb, the Python debugger, is a powerful interactive debugger which
1038 allows you to step through code, set breakpoints, watch variables,
1038 allows you to step through code, set breakpoints, watch variables,
1039 etc. IPython makes it very easy to start any script under the control
1039 etc. IPython makes it very easy to start any script under the control
1040 of pdb, regardless of whether you have wrapped it into a 'main()'
1040 of pdb, regardless of whether you have wrapped it into a 'main()'
1041 function or not. For this, simply type '%run -d myscript' at an
1041 function or not. For this, simply type '%run -d myscript' at an
1042 IPython prompt. See the %run command's documentation (via '%run?' or
1042 IPython prompt. See the %run command's documentation (via '%run?' or
1043 in Sec. magic_ for more details, including how to control where pdb
1043 in Sec. magic_ for more details, including how to control where pdb
1044 will stop execution first.
1044 will stop execution first.
1045
1045
1046 For more information on the use of the pdb debugger, read the included
1046 For more information on the use of the pdb debugger, read the included
1047 pdb.doc file (part of the standard Python distribution). On a stock
1047 pdb.doc file (part of the standard Python distribution). On a stock
1048 Linux system it is located at /usr/lib/python2.3/pdb.doc, but the
1048 Linux system it is located at /usr/lib/python2.3/pdb.doc, but the
1049 easiest way to read it is by using the help() function of the pdb module
1049 easiest way to read it is by using the help() function of the pdb module
1050 as follows (in an IPython prompt)::
1050 as follows (in an IPython prompt)::
1051
1051
1052 In [1]: import pdb
1052 In [1]: import pdb
1053 In [2]: pdb.help()
1053 In [2]: pdb.help()
1054
1054
1055 This will load the pdb.doc document in a file viewer for you automatically.
1055 This will load the pdb.doc document in a file viewer for you automatically.
1056
1056
1057
1057
1058 Automatic invocation of pdb on exceptions
1058 Automatic invocation of pdb on exceptions
1059 -----------------------------------------
1059 -----------------------------------------
1060
1060
1061 IPython, if started with the -pdb option (or if the option is set in
1061 IPython, if started with the -pdb option (or if the option is set in
1062 your rc file) can call the Python pdb debugger every time your code
1062 your rc file) can call the Python pdb debugger every time your code
1063 triggers an uncaught exception. This feature
1063 triggers an uncaught exception. This feature
1064 can also be toggled at any time with the %pdb magic command. This can be
1064 can also be toggled at any time with the %pdb magic command. This can be
1065 extremely useful in order to find the origin of subtle bugs, because pdb
1065 extremely useful in order to find the origin of subtle bugs, because pdb
1066 opens up at the point in your code which triggered the exception, and
1066 opens up at the point in your code which triggered the exception, and
1067 while your program is at this point 'dead', all the data is still
1067 while your program is at this point 'dead', all the data is still
1068 available and you can walk up and down the stack frame and understand
1068 available and you can walk up and down the stack frame and understand
1069 the origin of the problem.
1069 the origin of the problem.
1070
1070
1071 Furthermore, you can use these debugging facilities both with the
1071 Furthermore, you can use these debugging facilities both with the
1072 embedded IPython mode and without IPython at all. For an embedded shell
1072 embedded IPython mode and without IPython at all. For an embedded shell
1073 (see sec. Embedding_), simply call the constructor with
1073 (see sec. Embedding_), simply call the constructor with
1074 '--pdb' in the argument string and automatically pdb will be called if an
1074 '--pdb' in the argument string and automatically pdb will be called if an
1075 uncaught exception is triggered by your code.
1075 uncaught exception is triggered by your code.
1076
1076
1077 For stand-alone use of the feature in your programs which do not use
1077 For stand-alone use of the feature in your programs which do not use
1078 IPython at all, put the following lines toward the top of your 'main'
1078 IPython at all, put the following lines toward the top of your 'main'
1079 routine::
1079 routine::
1080
1080
1081 import sys
1081 import sys
1082 from IPython.core import ultratb
1082 from IPython.core import ultratb
1083 sys.excepthook = ultratb.FormattedTB(mode='Verbose',
1083 sys.excepthook = ultratb.FormattedTB(mode='Verbose',
1084 color_scheme='Linux', call_pdb=1)
1084 color_scheme='Linux', call_pdb=1)
1085
1085
1086 The mode keyword can be either 'Verbose' or 'Plain', giving either very
1086 The mode keyword can be either 'Verbose' or 'Plain', giving either very
1087 detailed or normal tracebacks respectively. The color_scheme keyword can
1087 detailed or normal tracebacks respectively. The color_scheme keyword can
1088 be one of 'NoColor', 'Linux' (default) or 'LightBG'. These are the same
1088 be one of 'NoColor', 'Linux' (default) or 'LightBG'. These are the same
1089 options which can be set in IPython with -colors and -xmode.
1089 options which can be set in IPython with -colors and -xmode.
1090
1090
1091 This will give any of your programs detailed, colored tracebacks with
1091 This will give any of your programs detailed, colored tracebacks with
1092 automatic invocation of pdb.
1092 automatic invocation of pdb.
1093
1093
1094
1094
1095 Extensions for syntax processing
1095 Extensions for syntax processing
1096 ================================
1096 ================================
1097
1097
1098 This isn't for the faint of heart, because the potential for breaking
1098 This isn't for the faint of heart, because the potential for breaking
1099 things is quite high. But it can be a very powerful and useful feature.
1099 things is quite high. But it can be a very powerful and useful feature.
1100 In a nutshell, you can redefine the way IPython processes the user input
1100 In a nutshell, you can redefine the way IPython processes the user input
1101 line to accept new, special extensions to the syntax without needing to
1101 line to accept new, special extensions to the syntax without needing to
1102 change any of IPython's own code.
1102 change any of IPython's own code.
1103
1103
1104 In the IPython/extensions directory you will find some examples
1104 In the IPython/extensions directory you will find some examples
1105 supplied, which we will briefly describe now. These can be used 'as is'
1105 supplied, which we will briefly describe now. These can be used 'as is'
1106 (and both provide very useful functionality), or you can use them as a
1106 (and both provide very useful functionality), or you can use them as a
1107 starting point for writing your own extensions.
1107 starting point for writing your own extensions.
1108
1108
1109
1109
1110 Pasting of code starting with '>>> ' or '... '
1110 Pasting of code starting with '>>> ' or '... '
1111 ----------------------------------------------
1111 ----------------------------------------------
1112
1112
1113 In the python tutorial it is common to find code examples which have
1113 In the python tutorial it is common to find code examples which have
1114 been taken from real python sessions. The problem with those is that all
1114 been taken from real python sessions. The problem with those is that all
1115 the lines begin with either '>>> ' or '... ', which makes it impossible
1115 the lines begin with either '>>> ' or '... ', which makes it impossible
1116 to paste them all at once. One must instead do a line by line manual
1116 to paste them all at once. One must instead do a line by line manual
1117 copying, carefully removing the leading extraneous characters.
1117 copying, carefully removing the leading extraneous characters.
1118
1118
1119 This extension identifies those starting characters and removes them
1119 This extension identifies those starting characters and removes them
1120 from the input automatically, so that one can paste multi-line examples
1120 from the input automatically, so that one can paste multi-line examples
1121 directly into IPython, saving a lot of time. Please look at the file
1121 directly into IPython, saving a lot of time. Please look at the file
1122 InterpreterPasteInput.py in the IPython/extensions directory for details
1122 InterpreterPasteInput.py in the IPython/extensions directory for details
1123 on how this is done.
1123 on how this is done.
1124
1124
1125 IPython comes with a special profile enabling this feature, called
1125 IPython comes with a special profile enabling this feature, called
1126 tutorial. Simply start IPython via 'ipython -p tutorial' and the feature
1126 tutorial. Simply start IPython via 'ipython -p tutorial' and the feature
1127 will be available. In a normal IPython session you can activate the
1127 will be available. In a normal IPython session you can activate the
1128 feature by importing the corresponding module with:
1128 feature by importing the corresponding module with:
1129 In [1]: import IPython.extensions.InterpreterPasteInput
1129 In [1]: import IPython.extensions.InterpreterPasteInput
1130
1130
1131 The following is a 'screenshot' of how things work when this extension
1131 The following is a 'screenshot' of how things work when this extension
1132 is on, copying an example from the standard tutorial::
1132 is on, copying an example from the standard tutorial::
1133
1133
1134 IPython profile: tutorial
1134 IPython profile: tutorial
1135
1135
1136 *** Pasting of code with ">>>" or "..." has been enabled.
1136 *** Pasting of code with ">>>" or "..." has been enabled.
1137
1137
1138 In [1]: >>> def fib2(n): # return Fibonacci series up to n
1138 In [1]: >>> def fib2(n): # return Fibonacci series up to n
1139 ...: ... """Return a list containing the Fibonacci series up to
1139 ...: ... """Return a list containing the Fibonacci series up to
1140 n."""
1140 n."""
1141 ...: ... result = []
1141 ...: ... result = []
1142 ...: ... a, b = 0, 1
1142 ...: ... a, b = 0, 1
1143 ...: ... while b < n:
1143 ...: ... while b < n:
1144 ...: ... result.append(b) # see below
1144 ...: ... result.append(b) # see below
1145 ...: ... a, b = b, a+b
1145 ...: ... a, b = b, a+b
1146 ...: ... return result
1146 ...: ... return result
1147 ...:
1147 ...:
1148
1148
1149 In [2]: fib2(10)
1149 In [2]: fib2(10)
1150 Out[2]: [1, 1, 2, 3, 5, 8]
1150 Out[2]: [1, 1, 2, 3, 5, 8]
1151
1151
1152 Note that as currently written, this extension does not recognize
1152 Note that as currently written, this extension does not recognize
1153 IPython's prompts for pasting. Those are more complicated, since the
1153 IPython's prompts for pasting. Those are more complicated, since the
1154 user can change them very easily, they involve numbers and can vary in
1154 user can change them very easily, they involve numbers and can vary in
1155 length. One could however extract all the relevant information from the
1155 length. One could however extract all the relevant information from the
1156 IPython instance and build an appropriate regular expression. This is
1156 IPython instance and build an appropriate regular expression. This is
1157 left as an exercise for the reader.
1157 left as an exercise for the reader.
1158
1158
1159
1159
1160 Input of physical quantities with units
1160 Input of physical quantities with units
1161 ---------------------------------------
1161 ---------------------------------------
1162
1162
1163 The module PhysicalQInput allows a simplified form of input for physical
1163 The module PhysicalQInput allows a simplified form of input for physical
1164 quantities with units. This file is meant to be used in conjunction with
1164 quantities with units. This file is meant to be used in conjunction with
1165 the PhysicalQInteractive module (in the same directory) and
1165 the PhysicalQInteractive module (in the same directory) and
1166 Physics.PhysicalQuantities from Konrad Hinsen's ScientificPython
1166 Physics.PhysicalQuantities from Konrad Hinsen's ScientificPython
1167 (http://dirac.cnrs-orleans.fr/ScientificPython/).
1167 (http://dirac.cnrs-orleans.fr/ScientificPython/).
1168
1168
1169 The Physics.PhysicalQuantities module defines PhysicalQuantity objects,
1169 The Physics.PhysicalQuantities module defines PhysicalQuantity objects,
1170 but these must be declared as instances of a class. For example, to
1170 but these must be declared as instances of a class. For example, to
1171 define v as a velocity of 3 m/s, normally you would write::
1171 define v as a velocity of 3 m/s, normally you would write::
1172
1172
1173 In [1]: v = PhysicalQuantity(3,'m/s')
1173 In [1]: v = PhysicalQuantity(3,'m/s')
1174
1174
1175 Using the PhysicalQ_Input extension this can be input instead as:
1175 Using the PhysicalQ_Input extension this can be input instead as:
1176 In [1]: v = 3 m/s
1176 In [1]: v = 3 m/s
1177 which is much more convenient for interactive use (even though it is
1177 which is much more convenient for interactive use (even though it is
1178 blatantly invalid Python syntax).
1178 blatantly invalid Python syntax).
1179
1179
1180 The physics profile supplied with IPython (enabled via 'ipython -p
1180 The physics profile supplied with IPython (enabled via 'ipython -p
1181 physics') uses these extensions, which you can also activate with:
1181 physics') uses these extensions, which you can also activate with:
1182
1182
1183 from math import * # math MUST be imported BEFORE PhysicalQInteractive
1183 from math import * # math MUST be imported BEFORE PhysicalQInteractive
1184 from IPython.extensions.PhysicalQInteractive import *
1184 from IPython.extensions.PhysicalQInteractive import *
1185 import IPython.extensions.PhysicalQInput
1185 import IPython.extensions.PhysicalQInput
1186
1186
1187 .. _gui_support:
1187 .. _gui_support:
1188
1188
1189 GUI event loop support support
1189 GUI event loop support support
1190 ==============================
1190 ==============================
1191
1191
1192 .. versionadded:: 0.11
1192 .. versionadded:: 0.11
1193 The ``%gui`` magic and :mod:`IPython.lib.inputhook`.
1193 The ``%gui`` magic and :mod:`IPython.lib.inputhook`.
1194
1194
1195 IPython has excellent support for working interactively with Graphical User
1195 IPython has excellent support for working interactively with Graphical User
1196 Interface (GUI) toolkits, such as wxPython, PyQt4, PyGTK and Tk. This is
1196 Interface (GUI) toolkits, such as wxPython, PyQt4, PyGTK and Tk. This is
1197 implemented using Python's builtin ``PyOSInputHook`` hook. This implementation
1197 implemented using Python's builtin ``PyOSInputHook`` hook. This implementation
1198 is extremely robust compared to our previous threaded based version. The
1198 is extremely robust compared to our previous threaded based version. The
1199 advantages of this are:
1199 advantages of this are:
1200
1200
1201 * GUIs can be enabled and disabled dynamically at runtime.
1201 * GUIs can be enabled and disabled dynamically at runtime.
1202 * The active GUI can be switched dynamically at runtime.
1202 * The active GUI can be switched dynamically at runtime.
1203 * In some cases, multiple GUIs can run simultaneously with no problems.
1203 * In some cases, multiple GUIs can run simultaneously with no problems.
1204 * There is a developer API in :mod:`IPython.lib.inputhook` for customizing
1204 * There is a developer API in :mod:`IPython.lib.inputhook` for customizing
1205 all of these things.
1205 all of these things.
1206
1206
1207 For users, enabling GUI event loop integration is simple. You simple use the
1207 For users, enabling GUI event loop integration is simple. You simple use the
1208 ``%gui`` magic as follows::
1208 ``%gui`` magic as follows::
1209
1209
1210 %gui [-a] [GUINAME]
1210 %gui [-a] [GUINAME]
1211
1211
1212 With no arguments, ``%gui`` removes all GUI support. Valid ``GUINAME``
1212 With no arguments, ``%gui`` removes all GUI support. Valid ``GUINAME``
1213 arguments are ``wx``, ``qt4``, ``gtk`` and ``tk``. The ``-a`` option will
1213 arguments are ``wx``, ``qt4``, ``gtk`` and ``tk``. The ``-a`` option will
1214 create and return a running application object for the selected GUI toolkit.
1214 create and return a running application object for the selected GUI toolkit.
1215
1215
1216 Thus, to use wxPython interactively and create a running :class:`wx.App`
1216 Thus, to use wxPython interactively and create a running :class:`wx.App`
1217 object, do::
1217 object, do::
1218
1218
1219 %gui -a wx
1219 %gui -a wx
1220
1220
1221 For information on IPython's Matplotlib integration (and the ``pylab`` mode)
1221 For information on IPython's Matplotlib integration (and the ``pylab`` mode)
1222 see :ref:`this section <matplotlib_support>`.
1222 see :ref:`this section <matplotlib_support>`.
1223
1223
1224 For developers that want to use IPython's GUI event loop integration in
1224 For developers that want to use IPython's GUI event loop integration in
1225 the form of a library, these capabilities are exposed in library form
1225 the form of a library, these capabilities are exposed in library form
1226 in the :mod:`IPython.lib.inputhook`. Interested developers should see the
1226 in the :mod:`IPython.lib.inputhook`. Interested developers should see the
1227 module docstrings for more information, but there are a few points that
1227 module docstrings for more information, but there are a few points that
1228 should be mentioned here.
1228 should be mentioned here.
1229
1229
1230 First, the ``PyOSInputHook`` approach only works in command line settings
1230 First, the ``PyOSInputHook`` approach only works in command line settings
1231 where readline is activated.
1231 where readline is activated.
1232
1232
1233 Second, when using the ``PyOSInputHook`` approach, a GUI application should
1233 Second, when using the ``PyOSInputHook`` approach, a GUI application should
1234 *not* start its event loop. Instead all of this is handled by the
1234 *not* start its event loop. Instead all of this is handled by the
1235 ``PyOSInputHook``. This means that applications that are meant to be used both
1235 ``PyOSInputHook``. This means that applications that are meant to be used both
1236 in IPython and as standalone apps need to have special code to detects how the
1236 in IPython and as standalone apps need to have special code to detects how the
1237 application is being run. We highly recommend using IPython's
1237 application is being run. We highly recommend using IPython's
1238 :func:`enable_foo` functions for this. Here is a simple example that shows the
1238 :func:`enable_foo` functions for this. Here is a simple example that shows the
1239 recommended code that should be at the bottom of a wxPython using GUI
1239 recommended code that should be at the bottom of a wxPython using GUI
1240 application::
1240 application::
1241
1241
1242 try:
1242 try:
1243 from IPython.lib.inputhook import enable_wx
1243 from IPython.lib.inputhook import enable_wx
1244 enable_wx(app)
1244 enable_wx(app)
1245 except ImportError:
1245 except ImportError:
1246 app.MainLoop()
1246 app.MainLoop()
1247
1247
1248 This pattern should be used instead of the simple ``app.MainLoop()`` code
1248 This pattern should be used instead of the simple ``app.MainLoop()`` code
1249 that a standalone wxPython application would have.
1249 that a standalone wxPython application would have.
1250
1250
1251 Third, unlike previous versions of IPython, we no longer "hijack" (replace
1251 Third, unlike previous versions of IPython, we no longer "hijack" (replace
1252 them with no-ops) the event loops. This is done to allow applications that
1252 them with no-ops) the event loops. This is done to allow applications that
1253 actually need to run the real event loops to do so. This is often needed to
1253 actually need to run the real event loops to do so. This is often needed to
1254 process pending events at critical points.
1254 process pending events at critical points.
1255
1255
1256 Finally, we also have a number of examples in our source directory
1256 Finally, we also have a number of examples in our source directory
1257 :file:`docs/examples/lib` that demonstrate these capabilities.
1257 :file:`docs/examples/lib` that demonstrate these capabilities.
1258
1258
1259 PyQt and PySide
1259 PyQt and PySide
1260 ---------------
1260 ---------------
1261
1261
1262 .. attempt at explanation of the complete mess that is Qt support
1262 .. attempt at explanation of the complete mess that is Qt support
1263
1263
1264 When you use ``gui=qt`` or ``pylab=qt``, IPython can work with either
1264 When you use ``gui=qt`` or ``pylab=qt``, IPython can work with either
1265 PyQt4 or PySide. There are three options for configuration here, because
1265 PyQt4 or PySide. There are three options for configuration here, because
1266 PyQt4 has two APIs for QString and QVariant - v1, which is the default on
1266 PyQt4 has two APIs for QString and QVariant - v1, which is the default on
1267 Python 2, and the more natural v2, which is the only API supported by PySide.
1267 Python 2, and the more natural v2, which is the only API supported by PySide.
1268 v2 is also the default for PyQt4 on Python 3. IPython's code for the QtConsole
1268 v2 is also the default for PyQt4 on Python 3. IPython's code for the QtConsole
1269 uses v2, but you can still use any interface in your code, since the
1269 uses v2, but you can still use any interface in your code, since the
1270 Qt frontend is in a different process.
1270 Qt frontend is in a different process.
1271
1271
1272 The default will be to import PyQt4 without configuration of the APIs, thus
1272 The default will be to import PyQt4 without configuration of the APIs, thus
1273 matching what most applications would expect. It will fall back of PySide if
1273 matching what most applications would expect. It will fall back of PySide if
1274 PyQt4 is unavailable.
1274 PyQt4 is unavailable.
1275
1275
1276 If specified, IPython will respect the environment variable ``QT_API`` used
1276 If specified, IPython will respect the environment variable ``QT_API`` used
1277 by ETS. ETS 4.0 also works with both PyQt4 and PySide, but it requires
1277 by ETS. ETS 4.0 also works with both PyQt4 and PySide, but it requires
1278 PyQt4 to use its v2 API. So if ``QT_API=pyside`` PySide will be used,
1278 PyQt4 to use its v2 API. So if ``QT_API=pyside`` PySide will be used,
1279 and if ``QT_API=pyqt`` then PyQt4 will be used *with the v2 API* for
1279 and if ``QT_API=pyqt`` then PyQt4 will be used *with the v2 API* for
1280 QString and QVariant, so ETS codes like MayaVi will also work with IPython.
1280 QString and QVariant, so ETS codes like MayaVi will also work with IPython.
1281
1281
1282 If you launch IPython in pylab mode with ``ipython pylab=qt``, then IPython
1282 If you launch IPython in pylab mode with ``ipython pylab=qt``, then IPython
1283 will ask matplotlib which Qt library to use (only if QT_API is *not set*),
1283 will ask matplotlib which Qt library to use (only if QT_API is *not set*),
1284 via the 'backend.qt4' rcParam.
1284 via the 'backend.qt4' rcParam.
1285 If matplotlib is version 1.0.1 or older, then IPython will always use PyQt4
1285 If matplotlib is version 1.0.1 or older, then IPython will always use PyQt4
1286 without setting the v2 APIs, since neither v2 PyQt nor PySide work.
1286 without setting the v2 APIs, since neither v2 PyQt nor PySide work.
1287
1287
1288 .. warning::
1288 .. warning::
1289
1289
1290 Note that this means for ETS 4 to work with PyQt4, ``QT_API`` *must* be set to
1290 Note that this means for ETS 4 to work with PyQt4, ``QT_API`` *must* be set to
1291 work with IPython's qt integration, because otherwise PyQt4 will be loaded in
1291 work with IPython's qt integration, because otherwise PyQt4 will be loaded in
1292 an incompatible mode.
1292 an incompatible mode.
1293
1293
1294 It also means that you must *not* have ``QT_API`` set if you want to
1294 It also means that you must *not* have ``QT_API`` set if you want to
1295 use ``gui=qt`` with code that requires PyQt4 API v1.
1295 use ``gui=qt`` with code that requires PyQt4 API v1.
1296
1296
1297
1297
1298
1298
1299 .. _matplotlib_support:
1299 .. _matplotlib_support:
1300
1300
1301 Plotting with matplotlib
1301 Plotting with matplotlib
1302 ========================
1302 ========================
1303
1303
1304
1304
1305 `Matplotlib`_ provides high quality 2D and
1305 `Matplotlib`_ provides high quality 2D and
1306 3D plotting for Python. Matplotlib can produce plots on screen using a variety
1306 3D plotting for Python. Matplotlib can produce plots on screen using a variety
1307 of GUI toolkits, including Tk, PyGTK, PyQt4 and wxPython. It also provides a
1307 of GUI toolkits, including Tk, PyGTK, PyQt4 and wxPython. It also provides a
1308 number of commands useful for scientific computing, all with a syntax
1308 number of commands useful for scientific computing, all with a syntax
1309 compatible with that of the popular Matlab program.
1309 compatible with that of the popular Matlab program.
1310
1310
1311 Many IPython users have come to rely on IPython's ``-pylab`` mode which
1311 Many IPython users have come to rely on IPython's ``-pylab`` mode which
1312 automates the integration of Matplotlib with IPython. We are still in the
1312 automates the integration of Matplotlib with IPython. We are still in the
1313 process of working with the Matplotlib developers to finalize the new pylab
1313 process of working with the Matplotlib developers to finalize the new pylab
1314 API, but for now you can use Matplotlib interactively using the following
1314 API, but for now you can use Matplotlib interactively using the following
1315 commands::
1315 commands::
1316
1316
1317 %gui -a wx
1317 %gui -a wx
1318 import matplotlib
1318 import matplotlib
1319 matplotlib.use('wxagg')
1319 matplotlib.use('wxagg')
1320 from matplotlib import pylab
1320 from matplotlib import pylab
1321 pylab.interactive(True)
1321 pylab.interactive(True)
1322
1322
1323 All of this will soon be automated as Matplotlib begins to include
1323 All of this will soon be automated as Matplotlib begins to include
1324 new logic that uses our new GUI support.
1324 new logic that uses our new GUI support.
1325
1325
1326 .. _Matplotlib: http://matplotlib.sourceforge.net
1326 .. _Matplotlib: http://matplotlib.sourceforge.net
1327
1327
1328 .. _interactive_demos:
1328 .. _interactive_demos:
1329
1329
1330 Interactive demos with IPython
1330 Interactive demos with IPython
1331 ==============================
1331 ==============================
1332
1332
1333 IPython ships with a basic system for running scripts interactively in
1333 IPython ships with a basic system for running scripts interactively in
1334 sections, useful when presenting code to audiences. A few tags embedded
1334 sections, useful when presenting code to audiences. A few tags embedded
1335 in comments (so that the script remains valid Python code) divide a file
1335 in comments (so that the script remains valid Python code) divide a file
1336 into separate blocks, and the demo can be run one block at a time, with
1336 into separate blocks, and the demo can be run one block at a time, with
1337 IPython printing (with syntax highlighting) the block before executing
1337 IPython printing (with syntax highlighting) the block before executing
1338 it, and returning to the interactive prompt after each block. The
1338 it, and returning to the interactive prompt after each block. The
1339 interactive namespace is updated after each block is run with the
1339 interactive namespace is updated after each block is run with the
1340 contents of the demo's namespace.
1340 contents of the demo's namespace.
1341
1341
1342 This allows you to show a piece of code, run it and then execute
1342 This allows you to show a piece of code, run it and then execute
1343 interactively commands based on the variables just created. Once you
1343 interactively commands based on the variables just created. Once you
1344 want to continue, you simply execute the next block of the demo. The
1344 want to continue, you simply execute the next block of the demo. The
1345 following listing shows the markup necessary for dividing a script into
1345 following listing shows the markup necessary for dividing a script into
1346 sections for execution as a demo:
1346 sections for execution as a demo:
1347
1347
1348 .. literalinclude:: ../../examples/lib/example-demo.py
1348 .. literalinclude:: ../../examples/lib/example-demo.py
1349 :language: python
1349 :language: python
1350
1350
1351
1351
1352 In order to run a file as a demo, you must first make a Demo object out
1352 In order to run a file as a demo, you must first make a Demo object out
1353 of it. If the file is named myscript.py, the following code will make a
1353 of it. If the file is named myscript.py, the following code will make a
1354 demo::
1354 demo::
1355
1355
1356 from IPython.lib.demo import Demo
1356 from IPython.lib.demo import Demo
1357
1357
1358 mydemo = Demo('myscript.py')
1358 mydemo = Demo('myscript.py')
1359
1359
1360 This creates the mydemo object, whose blocks you run one at a time by
1360 This creates the mydemo object, whose blocks you run one at a time by
1361 simply calling the object with no arguments. If you have autocall active
1361 simply calling the object with no arguments. If you have autocall active
1362 in IPython (the default), all you need to do is type::
1362 in IPython (the default), all you need to do is type::
1363
1363
1364 mydemo
1364 mydemo
1365
1365
1366 and IPython will call it, executing each block. Demo objects can be
1366 and IPython will call it, executing each block. Demo objects can be
1367 restarted, you can move forward or back skipping blocks, re-execute the
1367 restarted, you can move forward or back skipping blocks, re-execute the
1368 last block, etc. Simply use the Tab key on a demo object to see its
1368 last block, etc. Simply use the Tab key on a demo object to see its
1369 methods, and call '?' on them to see their docstrings for more usage
1369 methods, and call '?' on them to see their docstrings for more usage
1370 details. In addition, the demo module itself contains a comprehensive
1370 details. In addition, the demo module itself contains a comprehensive
1371 docstring, which you can access via::
1371 docstring, which you can access via::
1372
1372
1373 from IPython.lib import demo
1373 from IPython.lib import demo
1374
1374
1375 demo?
1375 demo?
1376
1376
1377 Limitations: It is important to note that these demos are limited to
1377 Limitations: It is important to note that these demos are limited to
1378 fairly simple uses. In particular, you can not put division marks in
1378 fairly simple uses. In particular, you can not put division marks in
1379 indented code (loops, if statements, function definitions, etc.)
1379 indented code (loops, if statements, function definitions, etc.)
1380 Supporting something like this would basically require tracking the
1380 Supporting something like this would basically require tracking the
1381 internal execution state of the Python interpreter, so only top-level
1381 internal execution state of the Python interpreter, so only top-level
1382 divisions are allowed. If you want to be able to open an IPython
1382 divisions are allowed. If you want to be able to open an IPython
1383 instance at an arbitrary point in a program, you can use IPython's
1383 instance at an arbitrary point in a program, you can use IPython's
1384 embedding facilities, described in detail in Sec. 9
1384 embedding facilities, described in detail in Sec. 9
1385
1385
@@ -1,391 +1,391 b''
1 ===============
1 ===============
2 0.11 Series
2 0.11 Series
3 ===============
3 ===============
4
4
5 Release 0.11
5 Release 0.11
6 ============
6 ============
7
7
8 IPython 0.11 is a *major* overhaul of IPython, two years in the making. Most of
8 IPython 0.11 is a *major* overhaul of IPython, two years in the making. Most of
9 the code base has been rewritten or at least reorganized, breaking backward compatibility
9 the code base has been rewritten or at least reorganized, breaking backward compatibility
10 with several APIs in previous versions. It is the first major release in two years, and
10 with several APIs in previous versions. It is the first major release in two years, and
11 probably the most significant change to IPython since its inception.
11 probably the most significant change to IPython since its inception.
12 As a result of the significant changes, we do plan to have a relatively quick
12 As a result of the significant changes, we do plan to have a relatively quick
13 succession of releases, as people discover new bugs and regressions.
13 succession of releases, as people discover new bugs and regressions.
14
14
15
15
16 Authors
16 Authors
17 -------
17 -------
18
18
19 Many users and developers contributed code, features, bug reports and ideas to
19 Many users and developers contributed code, features, bug reports and ideas to
20 this release. Please do not hesitate in contacting us if we've failed to
20 this release. Please do not hesitate in contacting us if we've failed to
21 acknowledge your contribution here. In particular, for this release we have
21 acknowledge your contribution here. In particular, for this release we have
22 contribution from the following people, a mix of new and regular names (in
22 contribution from the following people, a mix of new and regular names (in
23 alphabetical order by first name):
23 alphabetical order by first name):
24
24
25
25
26 * Andy Wilson <wilson.andrew.j+github-at-gmail.com>
26 * Andy Wilson <wilson.andrew.j+github-at-gmail.com>
27 * Aenugu Sai Kiran Reddy <saikrn08-at-gmail.com>
27 * Aenugu Sai Kiran Reddy <saikrn08-at-gmail.com>
28 * Antonio Cuni <antocuni>
28 * Antonio Cuni <antocuni>
29 * Barry Wark <barrywark-at-gmail.com>
29 * Barry Wark <barrywark-at-gmail.com>
30 * Beetoju Anuradha <anu.beethoju-at-gmail.com>
30 * Beetoju Anuradha <anu.beethoju-at-gmail.com>
31 * Brad Reisfeld
31 * Brad Reisfeld
32 * Brian Granger <ellisonbg-at-gmail.com>
32 * Brian Granger <ellisonbg-at-gmail.com>
33 * Cody Precord
33 * Cody Precord
34 * Darren Dale <dsdale24-at-gmail.com>
34 * Darren Dale <dsdale24-at-gmail.com>
35 * Dav Clark <davclark-at-berkeley.edu>
35 * Dav Clark <davclark-at-berkeley.edu>
36 * David Warde-Farley <wardefar-at-iro.umontreal.ca>
36 * David Warde-Farley <wardefar-at-iro.umontreal.ca>
37 * Eric Firing <efiring-at-hawaii.edu>
37 * Eric Firing <efiring-at-hawaii.edu>
38 * Erik Tollerud <erik.tollerud-at-gmail.com>
38 * Erik Tollerud <erik.tollerud-at-gmail.com>
39 * Evan Patterson <ejpatters-at-gmail.com>
39 * Evan Patterson <ejpatters-at-gmail.com>
40 * Fernando Perez <Fernando.Perez-at-berkeley.edu>
40 * Fernando Perez <Fernando.Perez-at-berkeley.edu>
41 * Gael Varoquaux <gael.varoquaux-at-normalesup.org>
41 * Gael Varoquaux <gael.varoquaux-at-normalesup.org>
42 * Gerardo <muzgash-at-Muzpelheim>
42 * Gerardo <muzgash-at-Muzpelheim>
43 * Jason Grout <jason.grout-at-drake.edu>
43 * Jason Grout <jason.grout-at-drake.edu>
44 * Jens Hedegaard Nielsen <jenshnielsen-at-gmail.com>
44 * Jens Hedegaard Nielsen <jenshnielsen-at-gmail.com>
45 * Justin Riley <justin.t.riley-at-gmail.com>
45 * Justin Riley <justin.t.riley-at-gmail.com>
46 * JΓΆrgen Stenarson <jorgen.stenarson-at-bostream.nu>
46 * JΓΆrgen Stenarson <jorgen.stenarson-at-bostream.nu>
47 * Kiorky
47 * Kiorky
48 * Laurent Dufrechou <laurent.dufrechou-at-gmail.com>
48 * Laurent Dufrechou <laurent.dufrechou-at-gmail.com>
49 * Luis Pedro Coelho <luis-at-luispedro.org>
49 * Luis Pedro Coelho <luis-at-luispedro.org>
50 * Mani chandra <mchandra-at-iitk.ac.in>
50 * Mani chandra <mchandra-at-iitk.ac.in>
51 * Mark E. Smith
51 * Mark E. Smith
52 * Mark Voorhies <mark.voorhies-at-ucsf.edu>
52 * Mark Voorhies <mark.voorhies-at-ucsf.edu>
53 * Martin Spacek <git-at-mspacek.mm.st>
53 * Martin Spacek <git-at-mspacek.mm.st>
54 * Michael Droettboom <mdroe-at-stsci.edu>
54 * Michael Droettboom <mdroe-at-stsci.edu>
55 * Min RK <benjaminrk-at-gmail.com>
55 * Min RK <benjaminrk-at-gmail.com>
56 * Nick Tarleton <nick-at-quixey.com>
56 * Nick Tarleton <nick-at-quixey.com>
57 * Nicolas Rougier <Nicolas.rougier-at-inria.fr>
57 * Nicolas Rougier <Nicolas.rougier-at-inria.fr>
58 * Omar Andres Zapata Mesa <andresete.chaos-at-gmail.com>
58 * Omar Andres Zapata Mesa <andresete.chaos-at-gmail.com>
59 * Paul Ivanov <pivanov314-at-gmail.com>
59 * Paul Ivanov <pivanov314-at-gmail.com>
60 * Pauli Virtanen <pauli.virtanen-at-iki.fi>
60 * Pauli Virtanen <pauli.virtanen-at-iki.fi>
61 * Prabhu Ramachandran
61 * Prabhu Ramachandran
62 * Ramana <sramana9-at-gmail.com>
62 * Ramana <sramana9-at-gmail.com>
63 * Robert Kern <robert.kern-at-gmail.com>
63 * Robert Kern <robert.kern-at-gmail.com>
64 * Sathesh Chandra <satheshchandra88-at-gmail.com>
64 * Sathesh Chandra <satheshchandra88-at-gmail.com>
65 * Satrajit Ghosh <satra-at-mit.edu>
65 * Satrajit Ghosh <satra-at-mit.edu>
66 * Sebastian Busch
66 * Sebastian Busch
67 * Stefan van der Walt <bzr-at-mentat.za.net>
67 * Stefan van der Walt <bzr-at-mentat.za.net>
68 * Stephan Peijnik <debian-at-sp.or.at>
68 * Stephan Peijnik <debian-at-sp.or.at>
69 * Steven Bethard
69 * Steven Bethard
70 * Thomas Kluyver <takowl-at-gmail.com>
70 * Thomas Kluyver <takowl-at-gmail.com>
71 * Thomas Spura <tomspur-at-fedoraproject.org>
71 * Thomas Spura <tomspur-at-fedoraproject.org>
72 * Tom Fetherston <tfetherston-at-aol.com>
72 * Tom Fetherston <tfetherston-at-aol.com>
73 * Tom MacWright
73 * Tom MacWright
74 * Ville M. Vainio <vivainio-at-gmail.com>
74 * Ville M. Vainio <vivainio-at-gmail.com>
75 * Vishal Vatsa <vishal.vatsa-at-gmail.com>
75 * Vishal Vatsa <vishal.vatsa-at-gmail.com>
76 * Vishnu S G <sgvishnu777-at-gmail.com>
76 * Vishnu S G <sgvishnu777-at-gmail.com>
77 * Walter Doerwald <walter-at-livinglogic.de>
77 * Walter Doerwald <walter-at-livinglogic.de>
78 * dan.milstein
78 * dan.milstein
79 * muzuiget <muzuiget-at-gmail.com>
79 * muzuiget <muzuiget-at-gmail.com>
80 * tzanko
80 * tzanko
81 * vankayala sowjanya <hai.sowjanya-at-gmail.com>
81 * vankayala sowjanya <hai.sowjanya-at-gmail.com>
82
82
83 .. note::
83 .. note::
84
84
85 This list was generated with the output of
85 This list was generated with the output of
86 ``git log dev-0.11 HEAD --format='* %aN <%aE>' | sed 's/@/\-at\-/' | sed 's/<>//' | sort -u``
86 ``git log dev-0.11 HEAD --format='* %aN <%aE>' | sed 's/@/\-at\-/' | sed 's/<>//' | sort -u``
87 after some cleanup. If you should be on this list, please add yourself.
87 after some cleanup. If you should be on this list, please add yourself.
88
88
89
89
90 Refactoring
90 Refactoring
91 -----------
91 -----------
92
92
93 As of the 0.11 version of IPython, a signifiant portion of the core has been
93 As of the 0.11 version of IPython, a signifiant portion of the core has been
94 refactored. This refactoring is founded on a number of new abstractions.
94 refactored. This refactoring is founded on a number of new abstractions.
95 The main new classes that implement these abstractions are:
95 The main new classes that implement these abstractions are:
96
96
97 * :class:`IPython.utils.traitlets.HasTraits`.
97 * :class:`IPython.utils.traitlets.HasTraits`.
98 * :class:`IPython.config.configurable.Configurable`.
98 * :class:`IPython.config.configurable.Configurable`.
99 * :class:`IPython.config.application.Application`.
99 * :class:`IPython.config.application.Application`.
100 * :class:`IPython.config.loader.ConfigLoader`.
100 * :class:`IPython.config.loader.ConfigLoader`.
101 * :class:`IPython.config.loader.Config`
101 * :class:`IPython.config.loader.Config`
102
102
103 We are still in the process of writing developer focused documentation about
103 We are still in the process of writing developer focused documentation about
104 these classes, but for now our :ref:`configuration documentation
104 these classes, but for now our :ref:`configuration documentation
105 <config_overview>` contains a high level overview of the concepts that these
105 <config_overview>` contains a high level overview of the concepts that these
106 classes express.
106 classes express.
107
107
108 The biggest user-visible change is likely the move to using the config system to
108 The biggest user-visible change is likely the move to using the config system to
109 determine the command-line arguments for IPython applications. The benefit of
109 determine the command-line arguments for IPython applications. The benefit of
110 this is that *all* configurable values in IPython are exposed on the
110 this is that *all* configurable values in IPython are exposed on the
111 command-line, but the syntax for specifying values has changed. The gist is that
111 command-line, but the syntax for specifying values has changed. The gist is that
112 assigning values is pure Python assignment, so there is always an '=', and never
112 assigning values is pure Python assignment, so there is always an '=', and never
113 a leading '-', nor a space separating key from value. Flags exist, to set
113 a leading '-', nor a space separating key from value. Flags exist, to set
114 multiple values or boolean flags, and these are always prefixed with '--', and
114 multiple values or boolean flags, and these are always prefixed with '--', and
115 never take arguments.
115 never take arguments.
116
116
117 ZMQ architecture
117 ZMQ architecture
118 ----------------
118 ----------------
119
119
120 There is a new GUI framework for IPython, based on a client-server model in
120 There is a new GUI framework for IPython, based on a client-server model in
121 which multiple clients can communicate with one IPython kernel, using the
121 which multiple clients can communicate with one IPython kernel, using the
122 ZeroMQ messaging framework. There is already a Qt console client, which can
122 ZeroMQ messaging framework. There is already a Qt console client, which can
123 be started by calling ``ipython qtconsole``. The protocol is :ref:`documented
123 be started by calling ``ipython qtconsole``. The protocol is :ref:`documented
124 <messaging>`.
124 <messaging>`.
125
125
126 The parallel computing framework has also been rewritten using ZMQ. The
126 The parallel computing framework has also been rewritten using ZMQ. The
127 protocol is described :ref:`here <parallel_messages>`, and the code is in the
127 protocol is described :ref:`here <parallel_messages>`, and the code is in the
128 new :mod:`IPython.parallel` module.
128 new :mod:`IPython.parallel` module.
129
129
130 Python 3 support
130 Python 3 support
131 ----------------
131 ----------------
132
132
133 A Python 3 version of IPython has been prepared. For the time being, this is
133 A Python 3 version of IPython has been prepared. For the time being, this is
134 maintained separately and updated from the main codebase. Its code can be found
134 maintained separately and updated from the main codebase. Its code can be found
135 `here <https://github.com/ipython/ipython-py3k>`_. The parallel computing
135 `here <https://github.com/ipython/ipython-py3k>`_. The parallel computing
136 components are not perfect on Python3, but most functionality appears to be
136 components are not perfect on Python3, but most functionality appears to be
137 working.
137 working.
138
138
139 Unicode
139 Unicode
140 -------
140 -------
141
141
142 Entering non-ascii characters in unicode literals (``u"€ø"``) now works properly
142 Entering non-ascii characters in unicode literals (``u"€ø"``) now works properly
143 on all platforms. However, entering these in byte/string literals (``"€ø"``)
143 on all platforms. However, entering these in byte/string literals (``"€ø"``)
144 will not work as expected on Windows (or any platform where the terminal encoding
144 will not work as expected on Windows (or any platform where the terminal encoding
145 is not UTF-8, as it typically is for Linux & Mac OS X). You can use escape sequences
145 is not UTF-8, as it typically is for Linux & Mac OS X). You can use escape sequences
146 (``"\xe9\x82"``) to get bytes above 128, or use unicode literals and encode
146 (``"\xe9\x82"``) to get bytes above 128, or use unicode literals and encode
147 them. This is a limitation of Python 2 which we cannot easily work around.
147 them. This is a limitation of Python 2 which we cannot easily work around.
148
148
149 New features
149 New features
150 ------------
150 ------------
151
151
152 * Added ``Bytes`` traitlet, removing ``Str``. All 'string' traitlets should
152 * Added ``Bytes`` traitlet, removing ``Str``. All 'string' traitlets should
153 either be ``Unicode`` if a real string, or ``Bytes`` if a C-string. This
153 either be ``Unicode`` if a real string, or ``Bytes`` if a C-string. This
154 removes ambiguity and helps the Python 3 transition.
154 removes ambiguity and helps the Python 3 transition.
155
155
156 * New magic ``%loadpy`` loads a python file from disk or web URL into
156 * New magic ``%loadpy`` loads a python file from disk or web URL into
157 the current input buffer.
157 the current input buffer.
158
158
159 * New magic ``%pastebin`` for sharing code via the 'Lodge it' pastebin.
159 * New magic ``%pastebin`` for sharing code via the 'Lodge it' pastebin.
160
160
161 * New magic ``%precision`` for controlling float and numpy pretty printing.
161 * New magic ``%precision`` for controlling float and numpy pretty printing.
162
162
163 * IPython applications initiate logging, so any object can gain access to
163 * IPython applications initiate logging, so any object can gain access to
164 a the logger of the currently running Application with:
164 a the logger of the currently running Application with:
165
165
166 .. sourcecode:: python
166 .. sourcecode:: python
167
167
168 from IPython.config.application import Application
168 from IPython.config.application import Application
169 logger = Application.instance().log
169 logger = Application.instance().log
170
170
171 * You can now get help on an object halfway through typing a command. For
171 * You can now get help on an object halfway through typing a command. For
172 instance, typing ``a = zip?`` shows the details of :func:`zip`. It also
172 instance, typing ``a = zip?`` shows the details of :func:`zip`. It also
173 leaves the command at the next prompt so you can carry on with it.
173 leaves the command at the next prompt so you can carry on with it.
174
174
175 * The input history is now written to an SQLite database. The API for
175 * The input history is now written to an SQLite database. The API for
176 retrieving items from the history has also been redesigned.
176 retrieving items from the history has also been redesigned.
177
177
178 * The :mod:`IPython.extensions.pretty` extension has been moved out of
178 * The :mod:`IPython.extensions.pretty` extension has been moved out of
179 quarantine and fully updated to the new extension API.
179 quarantine and fully updated to the new extension API.
180
180
181 * New magics for loading/unloading/reloading extensions have been added:
181 * New magics for loading/unloading/reloading extensions have been added:
182 ``%load_ext``, ``%unload_ext`` and ``%reload_ext``.
182 ``%load_ext``, ``%unload_ext`` and ``%reload_ext``.
183
183
184 * The configuration system and configuration files are brand new. See the
184 * The configuration system and configuration files are brand new. See the
185 configuration system :ref:`documentation <config_index>` for more details.
185 configuration system :ref:`documentation <config_index>` for more details.
186
186
187 * The :class:`~IPython.core.interactiveshell.InteractiveShell` class is now a
187 * The :class:`~IPython.core.interactiveshell.InteractiveShell` class is now a
188 :class:`~IPython.config.configurable.Configurable` subclass and has traitlets that
188 :class:`~IPython.config.configurable.Configurable` subclass and has traitlets that
189 determine the defaults and runtime environment. The ``__init__`` method has
189 determine the defaults and runtime environment. The ``__init__`` method has
190 also been refactored so this class can be instantiated and run without the
190 also been refactored so this class can be instantiated and run without the
191 old :mod:`ipmaker` module.
191 old :mod:`ipmaker` module.
192
192
193 * The methods of :class:`~IPython.core.interactiveshell.InteractiveShell` have
193 * The methods of :class:`~IPython.core.interactiveshell.InteractiveShell` have
194 been organized into sections to make it easier to turn more sections
194 been organized into sections to make it easier to turn more sections
195 of functionality into components.
195 of functionality into components.
196
196
197 * The embedded shell has been refactored into a truly standalone subclass of
197 * The embedded shell has been refactored into a truly standalone subclass of
198 :class:`InteractiveShell` called :class:`InteractiveShellEmbed`. All
198 :class:`InteractiveShell` called :class:`InteractiveShellEmbed`. All
199 embedding logic has been taken out of the base class and put into the
199 embedding logic has been taken out of the base class and put into the
200 embedded subclass.
200 embedded subclass.
201
201
202 * Added methods of :class:`~IPython.core.interactiveshell.InteractiveShell` to
202 * Added methods of :class:`~IPython.core.interactiveshell.InteractiveShell` to
203 help it cleanup after itself. The :meth:`cleanup` method controls this. We
203 help it cleanup after itself. The :meth:`cleanup` method controls this. We
204 couldn't do this in :meth:`__del__` because we have cycles in our object
204 couldn't do this in :meth:`__del__` because we have cycles in our object
205 graph that prevent it from being called.
205 graph that prevent it from being called.
206
206
207 * Created a new module :mod:`IPython.utils.importstring` for resolving
207 * Created a new module :mod:`IPython.utils.importstring` for resolving
208 strings like ``foo.bar.Bar`` to the actual class.
208 strings like ``foo.bar.Bar`` to the actual class.
209
209
210 * Completely refactored the :mod:`IPython.core.prefilter` module into
210 * Completely refactored the :mod:`IPython.core.prefilter` module into
211 :class:`~IPython.config.configurable.Configurable` subclasses. Added a new layer
211 :class:`~IPython.config.configurable.Configurable` subclasses. Added a new layer
212 into the prefilter system, called "transformations" that all new prefilter
212 into the prefilter system, called "transformations" that all new prefilter
213 logic should use (rather than the older "checker/handler" approach).
213 logic should use (rather than the older "checker/handler" approach).
214
214
215 * Aliases are now components (:mod:`IPython.core.alias`).
215 * Aliases are now components (:mod:`IPython.core.alias`).
216
216
217 * We are now using an internally shipped version of
217 * We are now using an internally shipped version of
218 :mod:`~IPython.external.argparse` to parse command line options for
218 :mod:`~IPython.external.argparse` to parse command line options for
219 :command:`ipython`.
219 :command:`ipython`.
220
220
221 * New top level :func:`~IPython.frontend.terminal.embed.embed` function that can
221 * New top level :func:`~IPython.frontend.terminal.embed.embed` function that can
222 be called to embed IPython at any place in user's code. One the first call it
222 be called to embed IPython at any place in user's code. One the first call it
223 will create an :class:`~IPython.frontend.terminal.embed.InteractiveShellEmbed`
223 will create an :class:`~IPython.frontend.terminal.embed.InteractiveShellEmbed`
224 instance and call it. In later calls, it just calls the previously created
224 instance and call it. In later calls, it just calls the previously created
225 :class:`~IPython.frontend.terminal.embed.InteractiveShellEmbed`.
225 :class:`~IPython.frontend.terminal.embed.InteractiveShellEmbed`.
226
226
227 * Created a configuration system (:mod:`IPython.config.configurable`) that is
227 * Created a configuration system (:mod:`IPython.config.configurable`) that is
228 based on :mod:`IPython.utils.traitlets`. Configurables are arranged into a
228 based on :mod:`IPython.utils.traitlets`. Configurables are arranged into a
229 runtime containment tree (not inheritance) that i) automatically propagates
229 runtime containment tree (not inheritance) that i) automatically propagates
230 configuration information and ii) allows singletons to discover each other in
230 configuration information and ii) allows singletons to discover each other in
231 a loosely coupled manner. In the future all parts of IPython will be
231 a loosely coupled manner. In the future all parts of IPython will be
232 subclasses of :class:`~IPython.config.configurable.Configurable`. All IPython
232 subclasses of :class:`~IPython.config.configurable.Configurable`. All IPython
233 developers should become familiar with the config system.
233 developers should become familiar with the config system.
234
234
235 * Created a new :class:`~IPython.config.loader.Config` for holding
235 * Created a new :class:`~IPython.config.loader.Config` for holding
236 configuration information. This is a dict like class with a few extras: i)
236 configuration information. This is a dict like class with a few extras: i)
237 it supports attribute style access, ii) it has a merge function that merges
237 it supports attribute style access, ii) it has a merge function that merges
238 two :class:`~IPython.config.loader.Config` instances recursively and iii) it
238 two :class:`~IPython.config.loader.Config` instances recursively and iii) it
239 will automatically create sub-:class:`~IPython.config.loader.Config`
239 will automatically create sub-:class:`~IPython.config.loader.Config`
240 instances for attributes that start with an uppercase character.
240 instances for attributes that start with an uppercase character.
241
241
242 * Created new configuration loaders in :mod:`IPython.config.loader`. These
242 * Created new configuration loaders in :mod:`IPython.config.loader`. These
243 loaders provide a unified loading interface for all configuration
243 loaders provide a unified loading interface for all configuration
244 information including command line arguments and configuration files. We
244 information including command line arguments and configuration files. We
245 have two default implementations based on :mod:`argparse` and plain python
245 have two default implementations based on :mod:`argparse` and plain python
246 files. These are used to implement the new configuration system.
246 files. These are used to implement the new configuration system.
247
247
248 * Created a top-level :class:`Application` class in
248 * Created a top-level :class:`Application` class in
249 :mod:`IPython.core.application` that is designed to encapsulate the starting
249 :mod:`IPython.core.application` that is designed to encapsulate the starting
250 of any basic Python program. An application loads and merges all the
250 of any basic Python program. An application loads and merges all the
251 configuration objects, constructs the main application, configures and
251 configuration objects, constructs the main application, configures and
252 initiates logging, and creates and configures any :class:`Configurable`
252 initiates logging, and creates and configures any :class:`Configurable`
253 instances and then starts the application running. An extended
253 instances and then starts the application running. An extended
254 :class:`BaseIPythonApplication` class adds logic for handling the
254 :class:`BaseIPythonApplication` class adds logic for handling the
255 IPython directory as well as profiles, and all IPython entry points
255 IPython directory as well as profiles, and all IPython entry points
256 extend it.
256 extend it.
257
257
258 * The :class:`Type` and :class:`Instance` traitlets now handle classes given
258 * The :class:`Type` and :class:`Instance` traitlets now handle classes given
259 as strings, like ``foo.bar.Bar``. This is needed for forward declarations.
259 as strings, like ``foo.bar.Bar``. This is needed for forward declarations.
260 But, this was implemented in a careful way so that string to class
260 But, this was implemented in a careful way so that string to class
261 resolution is done at a single point, when the parent
261 resolution is done at a single point, when the parent
262 :class:`~IPython.utils.traitlets.HasTraitlets` is instantiated.
262 :class:`~IPython.utils.traitlets.HasTraitlets` is instantiated.
263
263
264 * :mod:`IPython.utils.ipstruct` has been refactored to be a subclass of
264 * :mod:`IPython.utils.ipstruct` has been refactored to be a subclass of
265 dict. It also now has full docstrings and doctests.
265 dict. It also now has full docstrings and doctests.
266 * Created a Trait's like implementation in :mod:`IPython.utils.traitlets`.
266 * Created a Trait's like implementation in :mod:`IPython.utils.traitlets`.
267 This is a pure Python, lightweight version of a library that is similar to
267 This is a pure Python, lightweight version of a library that is similar to
268 :mod:`enthought.traits`. We are using this for validation, defaults and
268 :mod:`enthought.traits`. We are using this for validation, defaults and
269 notification in our new component system. Although it is not API compatible
269 notification in our new component system. Although it is not API compatible
270 with :mod:`enthought.traits`, we plan on moving in this direction so that
270 with :mod:`enthought.traits`, we plan on moving in this direction so that
271 eventually our implementation could be replaced by a (yet to exist) pure
271 eventually our implementation could be replaced by a (yet to exist) pure
272 Python version of :mod:`enthought.traits`.
272 Python version of :mod:`enthought.traits`.
273
273
274 * Added a new module :mod:`IPython.lib.inputhook` to manage the integration
274 * Added a new module :mod:`IPython.lib.inputhook` to manage the integration
275 with GUI event loops using `PyOS_InputHook`. See the docstrings in this
275 with GUI event loops using `PyOS_InputHook`. See the docstrings in this
276 module or the main IPython docs for details.
276 module or the main IPython docs for details.
277
277
278 * For users, GUI event loop integration is now handled through the new
278 * For users, GUI event loop integration is now handled through the new
279 :command:`%gui` magic command. Type ``%gui?`` at an IPython prompt for
279 :command:`%gui` magic command. Type ``%gui?`` at an IPython prompt for
280 documentation.
280 documentation.
281
281
282 * For developers :mod:`IPython.lib.inputhook` provides a simple interface
282 * For developers :mod:`IPython.lib.inputhook` provides a simple interface
283 for managing the event loops in their interactive GUI applications.
283 for managing the event loops in their interactive GUI applications.
284 Examples can be found in our :file:`docs/examples/lib` directory.
284 Examples can be found in our :file:`docs/examples/lib` directory.
285
285
286 Backwards incompatible changes
286 Backwards incompatible changes
287 ------------------------------
287 ------------------------------
288
288
289 * The Twisted-based :mod:`IPython.kernel` has been removed, and completely
289 * The Twisted-based :mod:`IPython.kernel` has been removed, and completely
290 rewritten as :mod:`IPython.parallel`, using ZeroMQ.
290 rewritten as :mod:`IPython.parallel`, using ZeroMQ.
291
291
292 * Profiles are now directories. Instead of a profile being a single config file,
292 * Profiles are now directories. Instead of a profile being a single config file,
293 profiles are now self-contained directories. By default, profiles get their
293 profiles are now self-contained directories. By default, profiles get their
294 own IPython history, log files, and everything. To create a new profile, do
294 own IPython history, log files, and everything. To create a new profile, do
295 ``ipython profile create <name>``.
295 ``ipython profile create <name>``.
296
296
297 * All IPython applications have been rewritten to use
297 * All IPython applications have been rewritten to use
298 :class:`~IPython.config.loader.KeyValueConfigLoader`. This means that
298 :class:`~IPython.config.loader.KeyValueConfigLoader`. This means that
299 command-line options have changed. Now, all configurable values are accessible
299 command-line options have changed. Now, all configurable values are accessible
300 from the command-line with the same syntax as in a configuration file.
300 from the command-line with the same syntax as in a configuration file.
301
301
302 * The command line options ``-wthread``, ``-qthread`` and
302 * The command line options ``-wthread``, ``-qthread`` and
303 ``-gthread`` have been removed. Use ``gui=wx``, ``gui=qt``, ``gui=gtk``
303 ``-gthread`` have been removed. Use ``--gui=wx``, ``--gui=qt``, ``--gui=gtk``
304 instead.
304 instead.
305
305
306 * The extension loading functions have been renamed to
306 * The extension loading functions have been renamed to
307 :func:`load_ipython_extension` and :func:`unload_ipython_extension`.
307 :func:`load_ipython_extension` and :func:`unload_ipython_extension`.
308
308
309 * :class:`~IPython.core.interactiveshell.InteractiveShell` no longer takes an
309 * :class:`~IPython.core.interactiveshell.InteractiveShell` no longer takes an
310 ``embedded`` argument. Instead just use the
310 ``embedded`` argument. Instead just use the
311 :class:`~IPython.core.interactiveshell.InteractiveShellEmbed` class.
311 :class:`~IPython.core.interactiveshell.InteractiveShellEmbed` class.
312
312
313 * ``__IPYTHON__`` is no longer injected into ``__builtin__``.
313 * ``__IPYTHON__`` is no longer injected into ``__builtin__``.
314
314
315 * :meth:`Struct.__init__` no longer takes `None` as its first argument. It
315 * :meth:`Struct.__init__` no longer takes `None` as its first argument. It
316 must be a :class:`dict` or :class:`Struct`.
316 must be a :class:`dict` or :class:`Struct`.
317
317
318 * :meth:`~IPython.core.interactiveshell.InteractiveShell.ipmagic` has been
318 * :meth:`~IPython.core.interactiveshell.InteractiveShell.ipmagic` has been
319 renamed :meth:`~IPython.core.interactiveshell.InteractiveShell.magic.`
319 renamed :meth:`~IPython.core.interactiveshell.InteractiveShell.magic.`
320
320
321 * The functions :func:`ipmagic` and :func:`ipalias` have been removed from
321 * The functions :func:`ipmagic` and :func:`ipalias` have been removed from
322 :mod:`__builtins__`.
322 :mod:`__builtins__`.
323
323
324 * The references to the global
324 * The references to the global
325 :class:`~IPython.core.interactivehell.InteractiveShell` instance (``_ip``, and
325 :class:`~IPython.core.interactivehell.InteractiveShell` instance (``_ip``, and
326 ``__IP``) have been removed from the user's namespace. They are replaced by a
326 ``__IP``) have been removed from the user's namespace. They are replaced by a
327 new function called :func:`get_ipython` that returns the current
327 new function called :func:`get_ipython` that returns the current
328 :class:`~IPython.core.interactiveshell.InteractiveShell` instance. This
328 :class:`~IPython.core.interactiveshell.InteractiveShell` instance. This
329 function is injected into the user's namespace and is now the main way of
329 function is injected into the user's namespace and is now the main way of
330 accessing the running IPython.
330 accessing the running IPython.
331
331
332 * Old style configuration files :file:`ipythonrc` and :file:`ipy_user_conf.py`
332 * Old style configuration files :file:`ipythonrc` and :file:`ipy_user_conf.py`
333 are no longer supported. Users should migrate there configuration files to
333 are no longer supported. Users should migrate there configuration files to
334 the new format described :ref:`here <config_overview>` and :ref:`here
334 the new format described :ref:`here <config_overview>` and :ref:`here
335 <configuring_ipython>`.
335 <configuring_ipython>`.
336
336
337 * The old IPython extension API that relied on :func:`ipapi` has been
337 * The old IPython extension API that relied on :func:`ipapi` has been
338 completely removed. The new extension API is described :ref:`here
338 completely removed. The new extension API is described :ref:`here
339 <configuring_ipython>`.
339 <configuring_ipython>`.
340
340
341 * Support for ``qt3`` has been dropped. Users who need this should use
341 * Support for ``qt3`` has been dropped. Users who need this should use
342 previous versions of IPython.
342 previous versions of IPython.
343
343
344 * Removed :mod:`shellglobals` as it was obsolete.
344 * Removed :mod:`shellglobals` as it was obsolete.
345
345
346 * Removed all the threaded shells in :mod:`IPython.core.shell`. These are no
346 * Removed all the threaded shells in :mod:`IPython.core.shell`. These are no
347 longer needed because of the new capabilities in
347 longer needed because of the new capabilities in
348 :mod:`IPython.lib.inputhook`.
348 :mod:`IPython.lib.inputhook`.
349
349
350 * New top-level sub-packages have been created: :mod:`IPython.core`,
350 * New top-level sub-packages have been created: :mod:`IPython.core`,
351 :mod:`IPython.lib`, :mod:`IPython.utils`, :mod:`IPython.deathrow`,
351 :mod:`IPython.lib`, :mod:`IPython.utils`, :mod:`IPython.deathrow`,
352 :mod:`IPython.quarantine`. All existing top-level modules have been
352 :mod:`IPython.quarantine`. All existing top-level modules have been
353 moved to appropriate sub-packages. All internal import statements
353 moved to appropriate sub-packages. All internal import statements
354 have been updated and tests have been added. The build system (setup.py
354 have been updated and tests have been added. The build system (setup.py
355 and friends) have been updated. See :ref:`this section <module_reorg>` of the
355 and friends) have been updated. See :ref:`this section <module_reorg>` of the
356 documentation for descriptions of these new sub-packages.
356 documentation for descriptions of these new sub-packages.
357
357
358 * :mod:`IPython.ipapi` has been moved to :mod:`IPython.core.ipapi`.
358 * :mod:`IPython.ipapi` has been moved to :mod:`IPython.core.ipapi`.
359 :mod:`IPython.Shell` and :mod:`IPython.iplib` have been split and removed as
359 :mod:`IPython.Shell` and :mod:`IPython.iplib` have been split and removed as
360 part of the refactor.
360 part of the refactor.
361
361
362 * :mod:`Extensions` has been moved to :mod:`extensions` and all existing
362 * :mod:`Extensions` has been moved to :mod:`extensions` and all existing
363 extensions have been moved to either :mod:`IPython.quarantine` or
363 extensions have been moved to either :mod:`IPython.quarantine` or
364 :mod:`IPython.deathrow`. :mod:`IPython.quarantine` contains modules that we
364 :mod:`IPython.deathrow`. :mod:`IPython.quarantine` contains modules that we
365 plan on keeping but that need to be updated. :mod:`IPython.deathrow`
365 plan on keeping but that need to be updated. :mod:`IPython.deathrow`
366 contains modules that are either dead or that should be maintained as third
366 contains modules that are either dead or that should be maintained as third
367 party libraries. More details about this can be found :ref:`here
367 party libraries. More details about this can be found :ref:`here
368 <module_reorg>`.
368 <module_reorg>`.
369
369
370 * Previous IPython GUIs in :mod:`IPython.frontend` and :mod:`IPython.gui` are
370 * Previous IPython GUIs in :mod:`IPython.frontend` and :mod:`IPython.gui` are
371 likely broken, and have been removed to :mod:`IPython.deathrow` because of the
371 likely broken, and have been removed to :mod:`IPython.deathrow` because of the
372 refactoring in the core. With proper updates, these should still work.
372 refactoring in the core. With proper updates, these should still work.
373
373
374
374
375 Known Regressions
375 Known Regressions
376 -----------------
376 -----------------
377
377
378 We do our best to improve IPython, but there are some known regressions in 0.11 relative
378 We do our best to improve IPython, but there are some known regressions in 0.11 relative
379 to 0.10.2.
379 to 0.10.2.
380
380
381 * The machinery that adds functionality to the 'sh' profile for using IPython as your
381 * The machinery that adds functionality to the 'sh' profile for using IPython as your
382 system shell has not been updated to use the new APIs. As a result, only the aesthetic
382 system shell has not been updated to use the new APIs. As a result, only the aesthetic
383 (prompt) changes are still implemented. We intend to fix this by 0.12.
383 (prompt) changes are still implemented. We intend to fix this by 0.12.
384
384
385 * The installation of scripts on Windows was broken without setuptools, so we now
385 * The installation of scripts on Windows was broken without setuptools, so we now
386 depend on setuptools on Windows. We hope to fix setuptools-less installation,
386 depend on setuptools on Windows. We hope to fix setuptools-less installation,
387 and then remove the setuptools dependency.
387 and then remove the setuptools dependency.
388
388
389 * Capitalised Exit and Quit have been dropped ways to exit IPython. The lowercase forms
389 * Capitalised Exit and Quit have been dropped ways to exit IPython. The lowercase forms
390 of both work either as a bare name (``exit``) or a function call (``exit()``).
390 of both work either as a bare name (``exit``) or a function call (``exit()``).
391 You can assign these to other names using exec_lines in the config file.
391 You can assign these to other names using exec_lines in the config file.
General Comments 0
You need to be logged in to leave comments. Login now