##// END OF EJS Templates
Updated manpage and docs to clarify negated options usage. Thanks to Stefan...
fperez -
Show More
@@ -1,586 +1,586 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 #*****************************************************************************
2 #*****************************************************************************
3 # Copyright (C) 2001-2004 Fernando Perez. <fperez@colorado.edu>
3 # Copyright (C) 2001-2004 Fernando Perez. <fperez@colorado.edu>
4 #
4 #
5 # Distributed under the terms of the BSD License. The full license is in
5 # Distributed under the terms of the BSD License. The full license is in
6 # the file COPYING, distributed as part of this software.
6 # the file COPYING, distributed as part of this software.
7 #*****************************************************************************
7 #*****************************************************************************
8
8
9 # $Id: usage.py 578 2005-05-13 21:16:51Z fperez $
9 # $Id: usage.py 926 2005-12-01 18:14:21Z fperez $
10
10
11 from IPython import Release
11 from IPython import Release
12 __author__ = '%s <%s>' % Release.authors['Fernando']
12 __author__ = '%s <%s>' % Release.authors['Fernando']
13 __license__ = Release.license
13 __license__ = Release.license
14 __version__ = Release.version
14 __version__ = Release.version
15
15
16 __doc__ = """
16 __doc__ = """
17 IPython -- An enhanced Interactive Python
17 IPython -- An enhanced Interactive Python
18 =========================================
18 =========================================
19
19
20 A Python shell with automatic history (input and output), dynamic object
20 A Python shell with automatic history (input and output), dynamic object
21 introspection, easier configuration, command completion, access to the system
21 introspection, easier configuration, command completion, access to the system
22 shell and more.
22 shell and more.
23
23
24 IPython can also be embedded in running programs. See EMBEDDING below.
24 IPython can also be embedded in running programs. See EMBEDDING below.
25
25
26
26
27 USAGE
27 USAGE
28 ipython [options] files
28 ipython [options] files
29
29
30 If invoked with no options, it executes all the files listed in
30 If invoked with no options, it executes all the files listed in
31 sequence and drops you into the interpreter while still acknowledging
31 sequence and drops you into the interpreter while still acknowledging
32 any options you may have set in your ipythonrc file. This behavior is
32 any options you may have set in your ipythonrc file. This behavior is
33 different from standard Python, which when called as python -i will
33 different from standard Python, which when called as python -i will
34 only execute one file and will ignore your configuration setup.
34 only execute one file and will ignore your configuration setup.
35
35
36 Please note that some of the configuration options are not available at
36 Please note that some of the configuration options are not available at
37 the command line, simply because they are not practical here. Look into
37 the command line, simply because they are not practical here. Look into
38 your ipythonrc configuration file for details on those. This file
38 your ipythonrc configuration file for details on those. This file
39 typically installed in the $HOME/.ipython directory.
39 typically installed in the $HOME/.ipython directory.
40
40
41 For Windows users, $HOME resolves to C:\\Documents and
41 For Windows users, $HOME resolves to C:\\Documents and
42 Settings\\YourUserName in most instances, and _ipython is used instead
42 Settings\\YourUserName in most instances, and _ipython is used instead
43 of .ipython, since some Win32 programs have problems with dotted names
43 of .ipython, since some Win32 programs have problems with dotted names
44 in directories.
44 in directories.
45
45
46 In the rest of this text, we will refer to this directory as
46 In the rest of this text, we will refer to this directory as
47 IPYTHONDIR.
47 IPYTHONDIR.
48
48
49
49
50 SPECIAL THREADING OPTIONS
50 SPECIAL THREADING OPTIONS
51 The following special options are ONLY valid at the beginning of the
51 The following special options are ONLY valid at the beginning of the
52 command line, and not later. This is because they control the initial-
52 command line, and not later. This is because they control the initial-
53 ization of ipython itself, before the normal option-handling mechanism
53 ization of ipython itself, before the normal option-handling mechanism
54 is active.
54 is active.
55
55
56 -gthread, -qthread, -wthread, -pylab
56 -gthread, -qthread, -wthread, -pylab
57
57
58 Only ONE of these can be given, and it can only be given as the
58 Only ONE of these can be given, and it can only be given as the
59 first option passed to IPython (it will have no effect in any
59 first option passed to IPython (it will have no effect in any
60 other position). They provide threading support for the GTK, QT
60 other position). They provide threading support for the GTK, QT
61 and WXWidgets toolkits, and for the matplotlib library.
61 and WXWidgets toolkits, and for the matplotlib library.
62
62
63 With any of the first three options, IPython starts running a
63 With any of the first three options, IPython starts running a
64 separate thread for the graphical toolkit's operation, so that
64 separate thread for the graphical toolkit's operation, so that
65 you can open and control graphical elements from within an
65 you can open and control graphical elements from within an
66 IPython command line, without blocking. All three provide
66 IPython command line, without blocking. All three provide
67 essentially the same functionality, respectively for GTK, QT and
67 essentially the same functionality, respectively for GTK, QT and
68 WXWidgets (via their Python interfaces).
68 WXWidgets (via their Python interfaces).
69
69
70 If -pylab is given, IPython loads special support for the mat-
70 If -pylab is given, IPython loads special support for the mat-
71 plotlib library (http://matplotlib.sourceforge.net), allowing
71 plotlib library (http://matplotlib.sourceforge.net), allowing
72 interactive usage of any of its backends as defined in the
72 interactive usage of any of its backends as defined in the
73 user's .matplotlibrc file. It automatically activates GTK, QT
73 user's .matplotlibrc file. It automatically activates GTK, QT
74 or WX threading for IPyhton if the choice of matplotlib backend
74 or WX threading for IPyhton if the choice of matplotlib backend
75 requires it. It also modifies the %run command to correctly
75 requires it. It also modifies the %run command to correctly
76 execute (without blocking) any matplotlib-based script which
76 execute (without blocking) any matplotlib-based script which
77 calls show() at the end.
77 calls show() at the end.
78
78
79 -tk The -g/q/wthread options, and -pylab (if matplotlib is
79 -tk The -g/q/wthread options, and -pylab (if matplotlib is
80 configured to use GTK, QT or WX), will normally block Tk
80 configured to use GTK, QT or WX), will normally block Tk
81 graphical interfaces. This means that when GTK, QT or WX
81 graphical interfaces. This means that when GTK, QT or WX
82 threading is active, any attempt to open a Tk GUI will result in
82 threading is active, any attempt to open a Tk GUI will result in
83 a dead window, and possibly cause the Python interpreter to
83 a dead window, and possibly cause the Python interpreter to
84 crash. An extra option, -tk, is available to address this
84 crash. An extra option, -tk, is available to address this
85 issue. It can ONLY be given as a SECOND option after any of the
85 issue. It can ONLY be given as a SECOND option after any of the
86 above (-gthread, -qthread, -wthread or -pylab).
86 above (-gthread, -qthread, -wthread or -pylab).
87
87
88 If -tk is given, IPython will try to coordinate Tk threading
88 If -tk is given, IPython will try to coordinate Tk threading
89 with GTK, QT or WX. This is however potentially unreliable, and
89 with GTK, QT or WX. This is however potentially unreliable, and
90 you will have to test on your platform and Python configuration
90 you will have to test on your platform and Python configuration
91 to determine whether it works for you. Debian users have
91 to determine whether it works for you. Debian users have
92 reported success, apparently due to the fact that Debian builds
92 reported success, apparently due to the fact that Debian builds
93 all of Tcl, Tk, Tkinter and Python with pthreads support. Under
93 all of Tcl, Tk, Tkinter and Python with pthreads support. Under
94 other Linux environments (such as Fedora Core 2/3), this option
94 other Linux environments (such as Fedora Core 2/3), this option
95 has caused random crashes and lockups of the Python interpreter.
95 has caused random crashes and lockups of the Python interpreter.
96 Under other operating systems (Mac OSX and Windows), you'll need
96 Under other operating systems (Mac OSX and Windows), you'll need
97 to try it to find out, since currently no user reports are
97 to try it to find out, since currently no user reports are
98 available.
98 available.
99
99
100 There is unfortunately no way for IPython to determine at run-
100 There is unfortunately no way for IPython to determine at run-
101 time whether -tk will work reliably or not, so you will need to
101 time whether -tk will work reliably or not, so you will need to
102 do some experiments before relying on it for regular work.
102 do some experiments before relying on it for regular work.
103
103
104 A WARNING ABOUT SIGNALS AND THREADS
104 A WARNING ABOUT SIGNALS AND THREADS
105
105
106 When any of the thread systems (GTK, QT or WX) are active, either
106 When any of the thread systems (GTK, QT or WX) are active, either
107 directly or via -pylab with a threaded backend, it is impossible to
107 directly or via -pylab with a threaded backend, it is impossible to
108 interrupt long-running Python code via Ctrl-C. IPython can not pass
108 interrupt long-running Python code via Ctrl-C. IPython can not pass
109 the KeyboardInterrupt exception (or the underlying SIGINT) across
109 the KeyboardInterrupt exception (or the underlying SIGINT) across
110 threads, so any long-running process started from IPython will run to
110 threads, so any long-running process started from IPython will run to
111 completion, or will have to be killed via an external (OS-based)
111 completion, or will have to be killed via an external (OS-based)
112 mechanism.
112 mechanism.
113
113
114 To the best of my knowledge, this limitation is imposed by the Python
114 To the best of my knowledge, this limitation is imposed by the Python
115 interpreter itself, and it comes from the difficulty of writing
115 interpreter itself, and it comes from the difficulty of writing
116 portable signal/threaded code. If any user is an expert on this topic
116 portable signal/threaded code. If any user is an expert on this topic
117 and can suggest a better solution, I would love to hear about it. In
117 and can suggest a better solution, I would love to hear about it. In
118 the IPython sources, look at the Shell.py module, and in particular at
118 the IPython sources, look at the Shell.py module, and in particular at
119 the runcode() method.
119 the runcode() method.
120
120
121 REGULAR OPTIONS
121 REGULAR OPTIONS
122 After the above threading options have been given, regular options can
122 After the above threading options have been given, regular options can
123 follow in any order. All options can be abbreviated to their shortest
123 follow in any order. All options can be abbreviated to their shortest
124 non-ambiguous form and are case-sensitive. One or two dashes can be
124 non-ambiguous form and are case-sensitive. One or two dashes can be
125 used. Some options have an alternate short form, indicated after a |.
125 used. Some options have an alternate short form, indicated after a |.
126
126
127 Most options can also be set from your ipythonrc configuration file.
127 Most options can also be set from your ipythonrc configuration file.
128 See the provided examples for assistance. Options given on the comman-
128 See the provided examples for assistance. Options given on the comman-
129 dline override the values set in the ipythonrc file.
129 dline override the values set in the ipythonrc file.
130
130
131 All options with a no| prepended can be specified in ’no’ form (-noop-
131 All options with a [no] prepended can be specified in negated form
132 tion instead of -option) to turn the feature off.
132 (using -nooption instead of -option) to turn the feature off.
133
133
134 -h, --help
134 -h, --help
135 Show summary of options.
135 Show summary of options.
136
136
137 -pylab This can only be given as the first option passed to IPython (it
137 -pylab This can only be given as the first option passed to IPython (it
138 will have no effect in any other position). It adds special sup-
138 will have no effect in any other position). It adds special sup-
139 port for the matplotlib library (http://matplotlib.source-
139 port for the matplotlib library (http://matplotlib.source-
140 forge.net), allowing interactive usage of any of its backends as
140 forge.net), allowing interactive usage of any of its backends as
141 defined in the user’s .matplotlibrc file. It automatically
141 defined in the user’s .matplotlibrc file. It automatically
142 activates GTK or WX threading for IPyhton if the choice of mat-
142 activates GTK or WX threading for IPyhton if the choice of mat-
143 plotlib backend requires it. It also modifies the @run command
143 plotlib backend requires it. It also modifies the @run command
144 to correctly execute (without blocking) any matplotlib-based
144 to correctly execute (without blocking) any matplotlib-based
145 script which calls show() at the end.
145 script which calls show() at the end.
146
146
147 -no|autocall
147 -[no]autocall
148 Make IPython automatically call any callable object even if you
148 Make IPython automatically call any callable object even if you
149 didn’t type explicit parentheses. For example, ’str 43’ becomes
149 didn’t type explicit parentheses. For example, ’str 43’ becomes
150 ’str(43)’ automatically.
150 ’str(43)’ automatically.
151
151
152 -no|autoindent
152 -[no]autoindent
153 Turn automatic indentation on/off.
153 Turn automatic indentation on/off.
154
154
155 -no|automagic
155 -[no]automagic
156 Make magic commands automatic (without needing their first char-
156 Make magic commands automatic (without needing their first char-
157 acter to be @). Type @magic at the IPython prompt for more
157 acter to be @). Type @magic at the IPython prompt for more
158 information.
158 information.
159
159
160 -no|autoparens
160 -[no]autoparens
161 Make IPython automatically call any callable object even if you
161 Make IPython automatically call any callable object even if you
162 didn’t type explicit parentheses. For example, ’str 43’ becomes
162 didn’t type explicit parentheses. For example, ’str 43’ becomes
163 ’str(43)’ automatically.
163 ’str(43)’ automatically.
164
164
165 -no|banner
165 -[no]banner
166 Print the intial information banner (default on).
166 Print the intial information banner (default on).
167
167
168 -c <command>
168 -c <command>
169 Execute the given command string, and set sys.argv to [’c’].
169 Execute the given command string, and set sys.argv to [’c’].
170 This is similar to the -c option in the normal Python inter-
170 This is similar to the -c option in the normal Python inter-
171 preter.
171 preter.
172
172
173 -cache_size|cs <n>
173 -cache_size|cs <n>
174 Size of the output cache (maximum number of entries to hold in
174 Size of the output cache (maximum number of entries to hold in
175 memory). The default is 1000, you can change it permanently in
175 memory). The default is 1000, you can change it permanently in
176 your config file. Setting it to 0 completely disables the
176 your config file. Setting it to 0 completely disables the
177 caching system, and the minimum value accepted is 20 (if you
177 caching system, and the minimum value accepted is 20 (if you
178 provide a value less than 20, it is reset to 0 and a warning is
178 provide a value less than 20, it is reset to 0 and a warning is
179 issued). This limit is defined because otherwise you’ll spend
179 issued). This limit is defined because otherwise you’ll spend
180 more time re-flushing a too small cache than working.
180 more time re-flushing a too small cache than working.
181
181
182 -classic|cl
182 -classic|cl
183 Gives IPython a similar feel to the classic Python prompt.
183 Gives IPython a similar feel to the classic Python prompt.
184
184
185 -colors <scheme>
185 -colors <scheme>
186 Color scheme for prompts and exception reporting. Currently
186 Color scheme for prompts and exception reporting. Currently
187 implemented: NoColor, Linux, and LightBG.
187 implemented: NoColor, Linux, and LightBG.
188
188
189 -no|color_info
189 -[no]color_info
190 IPython can display information about objects via a set of func-
190 IPython can display information about objects via a set of func-
191 tions, and optionally can use colors for this, syntax highlight-
191 tions, and optionally can use colors for this, syntax highlight-
192 ing source code and various other elements. However, because
192 ing source code and various other elements. However, because
193 this information is passed through a pager (like ’less’) and
193 this information is passed through a pager (like ’less’) and
194 many pagers get confused with color codes, this option is off by
194 many pagers get confused with color codes, this option is off by
195 default. You can test it and turn it on permanently in your
195 default. You can test it and turn it on permanently in your
196 ipythonrc file if it works for you. As a reference, the ’less’
196 ipythonrc file if it works for you. As a reference, the ’less’
197 pager supplied with Mandrake 8.2 works ok, but that in RedHat
197 pager supplied with Mandrake 8.2 works ok, but that in RedHat
198 7.2 doesn’t.
198 7.2 doesn’t.
199
199
200 Test it and turn it on permanently if it works with your system.
200 Test it and turn it on permanently if it works with your system.
201 The magic function @color_info allows you to toggle this inter-
201 The magic function @color_info allows you to toggle this inter-
202 actively for testing.
202 actively for testing.
203
203
204 -no|confirm_exit
204 -[no]confirm_exit
205 Set to confirm when you try to exit IPython with an EOF (Con-
205 Set to confirm when you try to exit IPython with an EOF (Con-
206 trol-D in Unix, Control-Z/Enter in Windows). Note that using the
206 trol-D in Unix, Control-Z/Enter in Windows). Note that using the
207 magic functions @Exit or @Quit you can force a direct exit,
207 magic functions @Exit or @Quit you can force a direct exit,
208 bypassing any confirmation.
208 bypassing any confirmation.
209
209
210 -no|debug
210 -[no]debug
211 Show information about the loading process. Very useful to pin
211 Show information about the loading process. Very useful to pin
212 down problems with your configuration files or to get details
212 down problems with your configuration files or to get details
213 about session restores.
213 about session restores.
214
214
215 -no|deep_reload
215 -[no]deep_reload
216 IPython can use the deep_reload module which reloads changes in
216 IPython can use the deep_reload module which reloads changes in
217 modules recursively (it replaces the reload() function, so you
217 modules recursively (it replaces the reload() function, so you
218 don’t need to change anything to use it). deep_reload() forces a
218 don’t need to change anything to use it). deep_reload() forces a
219 full reload of modules whose code may have changed, which the
219 full reload of modules whose code may have changed, which the
220 default reload() function does not.
220 default reload() function does not.
221
221
222 When deep_reload is off, IPython will use the normal reload(),
222 When deep_reload is off, IPython will use the normal reload(),
223 but deep_reload will still be available as dreload(). This fea-
223 but deep_reload will still be available as dreload(). This fea-
224 ture is off by default [which means that you have both normal
224 ture is off by default [which means that you have both normal
225 reload() and dreload()].
225 reload() and dreload()].
226
226
227 -editor <name>
227 -editor <name>
228 Which editor to use with the @edit command. By default, IPython
228 Which editor to use with the @edit command. By default, IPython
229 will honor your EDITOR environment variable (if not set, vi is
229 will honor your EDITOR environment variable (if not set, vi is
230 the Unix default and notepad the Windows one). Since this editor
230 the Unix default and notepad the Windows one). Since this editor
231 is invoked on the fly by IPython and is meant for editing small
231 is invoked on the fly by IPython and is meant for editing small
232 code snippets, you may want to use a small, lightweight editor
232 code snippets, you may want to use a small, lightweight editor
233 here (in case your default EDITOR is something like Emacs).
233 here (in case your default EDITOR is something like Emacs).
234
234
235 -ipythondir <name>
235 -ipythondir <name>
236 The name of your IPython configuration directory IPYTHONDIR.
236 The name of your IPython configuration directory IPYTHONDIR.
237 This can also be specified through the environment variable
237 This can also be specified through the environment variable
238 IPYTHONDIR.
238 IPYTHONDIR.
239
239
240 -log|l Generate a log file of all input. The file is named ipython.log
240 -log|l Generate a log file of all input. The file is named ipython.log
241 in your current directory (which prevents logs from multiple
241 in your current directory (which prevents logs from multiple
242 IPython sessions from trampling each other). You can use this to
242 IPython sessions from trampling each other). You can use this to
243 later restore a session by loading your logfile as a file to be
243 later restore a session by loading your logfile as a file to be
244 executed with option -logplay (see below).
244 executed with option -logplay (see below).
245
245
246 -logfile|lf
246 -logfile|lf
247 Specifu the name of your logfile.
247 Specifu the name of your logfile.
248
248
249 -logplay|lp
249 -logplay|lp
250 Replay a previous log. For restoring a session as close as pos-
250 Replay a previous log. For restoring a session as close as pos-
251 sible to the state you left it in, use this option (don’t just
251 sible to the state you left it in, use this option (don’t just
252 run the logfile). With -logplay, IPython will try to reconstruct
252 run the logfile). With -logplay, IPython will try to reconstruct
253 the previous working environment in full, not just execute the
253 the previous working environment in full, not just execute the
254 commands in the logfile.
254 commands in the logfile.
255 When a session is restored, logging is automatically turned on
255 When a session is restored, logging is automatically turned on
256 again with the name of the logfile it was invoked with (it is
256 again with the name of the logfile it was invoked with (it is
257 read from the log header). So once you’ve turned logging on for
257 read from the log header). So once you’ve turned logging on for
258 a session, you can quit IPython and reload it as many times as
258 a session, you can quit IPython and reload it as many times as
259 you want and it will continue to log its history and restore
259 you want and it will continue to log its history and restore
260 from the beginning every time.
260 from the beginning every time.
261
261
262 Caveats: there are limitations in this option. The history vari-
262 Caveats: there are limitations in this option. The history vari-
263 ables _i*,_* and _dh don’t get restored properly. In the future
263 ables _i*,_* and _dh don’t get restored properly. In the future
264 we will try to implement full session saving by writing and
264 we will try to implement full session saving by writing and
265 retrieving a failed because of inherent limitations of Python’s
265 retrieving a failed because of inherent limitations of Python’s
266 Pickle module, so this may have to wait.
266 Pickle module, so this may have to wait.
267
267
268 -no|messages
268 -[no]messages
269 Print messages which IPython collects about its startup process
269 Print messages which IPython collects about its startup process
270 (default on).
270 (default on).
271
271
272 -no|pdb
272 -[no]pdb
273 Automatically call the pdb debugger after every uncaught excep-
273 Automatically call the pdb debugger after every uncaught excep-
274 tion. If you are used to debugging using pdb, this puts you
274 tion. If you are used to debugging using pdb, this puts you
275 automatically inside of it after any call (either in IPython or
275 automatically inside of it after any call (either in IPython or
276 in code called by it) which triggers an exception which goes
276 in code called by it) which triggers an exception which goes
277 uncaught.
277 uncaught.
278
278
279 -no|pprint
279 -[no]pprint
280 IPython can optionally use the pprint (pretty printer) module
280 IPython can optionally use the pprint (pretty printer) module
281 for displaying results. pprint tends to give a nicer display of
281 for displaying results. pprint tends to give a nicer display of
282 nested data structures. If you like it, you can turn it on per-
282 nested data structures. If you like it, you can turn it on per-
283 manently in your config file (default off).
283 manently in your config file (default off).
284
284
285 -profile|p <name>
285 -profile|p <name>
286 Assume that your config file is ipythonrc-<name> (looks in cur-
286 Assume that your config file is ipythonrc-<name> (looks in cur-
287 rent dir first, then in IPYTHONDIR). This is a quick way to keep
287 rent dir first, then in IPYTHONDIR). This is a quick way to keep
288 and load multiple config files for different tasks, especially
288 and load multiple config files for different tasks, especially
289 if you use the include option of config files. You can keep a
289 if you use the include option of config files. You can keep a
290 basic IPYTHONDIR/ipythonrc file and then have other ’profiles’
290 basic IPYTHONDIR/ipythonrc file and then have other ’profiles’
291 which include this one and load extra things for particular
291 which include this one and load extra things for particular
292 tasks. For example:
292 tasks. For example:
293
293
294 1) $HOME/.ipython/ipythonrc : load basic things you always want.
294 1) $HOME/.ipython/ipythonrc : load basic things you always want.
295 2) $HOME/.ipython/ipythonrc-math : load (1) and basic math-
295 2) $HOME/.ipython/ipythonrc-math : load (1) and basic math-
296 related modules.
296 related modules.
297 3) $HOME/.ipython/ipythonrc-numeric : load (1) and Numeric and
297 3) $HOME/.ipython/ipythonrc-numeric : load (1) and Numeric and
298 plotting modules.
298 plotting modules.
299
299
300 Since it is possible to create an endless loop by having circu-
300 Since it is possible to create an endless loop by having circu-
301 lar file inclusions, IPython will stop if it reaches 15 recur-
301 lar file inclusions, IPython will stop if it reaches 15 recur-
302 sive inclusions.
302 sive inclusions.
303
303
304 -prompt_in1|pi1 <string>
304 -prompt_in1|pi1 <string>
305 Specify the string used for input prompts. Note that if you are
305 Specify the string used for input prompts. Note that if you are
306 using numbered prompts, the number is represented with a ’\#’ in
306 using numbered prompts, the number is represented with a ’\#’ in
307 the string. Don’t forget to quote strings with spaces embedded
307 the string. Don’t forget to quote strings with spaces embedded
308 in them. Default: ’In [\#]:’.
308 in them. Default: ’In [\#]:’.
309
309
310 Most bash-like escapes can be used to customize IPython’s
310 Most bash-like escapes can be used to customize IPython’s
311 prompts, as well as a few additional ones which are IPython-spe-
311 prompts, as well as a few additional ones which are IPython-spe-
312 cific. All valid prompt escapes are described in detail in the
312 cific. All valid prompt escapes are described in detail in the
313 Customization section of the IPython HTML/PDF manual.
313 Customization section of the IPython HTML/PDF manual.
314
314
315 -prompt_in2|pi2 <string>
315 -prompt_in2|pi2 <string>
316 Similar to the previous option, but used for the continuation
316 Similar to the previous option, but used for the continuation
317 prompts. The special sequence ’\D’ is similar to ’\#’, but with
317 prompts. The special sequence ’\D’ is similar to ’\#’, but with
318 all digits replaced dots (so you can have your continuation
318 all digits replaced dots (so you can have your continuation
319 prompt aligned with your input prompt). Default: ’ .\D.:’
319 prompt aligned with your input prompt). Default: ’ .\D.:’
320 (note three spaces at the start for alignment with ’In [\#]’).
320 (note three spaces at the start for alignment with ’In [\#]’).
321
321
322 -prompt_out|po <string>
322 -prompt_out|po <string>
323 String used for output prompts, also uses numbers like
323 String used for output prompts, also uses numbers like
324 prompt_in1. Default: ’Out[\#]:’.
324 prompt_in1. Default: ’Out[\#]:’.
325
325
326 -quick Start in bare bones mode (no config file loaded).
326 -quick Start in bare bones mode (no config file loaded).
327
327
328 -rcfile <name>
328 -rcfile <name>
329 Name of your IPython resource configuration file. normally
329 Name of your IPython resource configuration file. normally
330 IPython loads ipythonrc (from current directory) or
330 IPython loads ipythonrc (from current directory) or
331 IPYTHONDIR/ipythonrc. If the loading of your config file fails,
331 IPYTHONDIR/ipythonrc. If the loading of your config file fails,
332 IPython starts with a bare bones configuration (no modules
332 IPython starts with a bare bones configuration (no modules
333 loaded at all).
333 loaded at all).
334
334
335 -no|readline
335 -[no]readline
336 Use the readline library, which is needed to support name com-
336 Use the readline library, which is needed to support name com-
337 pletion and command history, among other things. It is enabled
337 pletion and command history, among other things. It is enabled
338 by default, but may cause problems for users of X/Emacs in
338 by default, but may cause problems for users of X/Emacs in
339 Python comint or shell buffers.
339 Python comint or shell buffers.
340
340
341 Note that emacs ’eterm’ buffers (opened with M-x term) support
341 Note that emacs ’eterm’ buffers (opened with M-x term) support
342 IPython’s readline and syntax coloring fine, only ’emacs’ (M-x
342 IPython’s readline and syntax coloring fine, only ’emacs’ (M-x
343 shell and C-c !) buffers do not.
343 shell and C-c !) buffers do not.
344
344
345 -screen_length|sl <n>
345 -screen_length|sl <n>
346 Number of lines of your screen. This is used to control print-
346 Number of lines of your screen. This is used to control print-
347 ing of very long strings. Strings longer than this number of
347 ing of very long strings. Strings longer than this number of
348 lines will be sent through a pager instead of directly printed.
348 lines will be sent through a pager instead of directly printed.
349
349
350 The default value for this is 0, which means IPython will auto-
350 The default value for this is 0, which means IPython will auto-
351 detect your screen size every time it needs to print certain
351 detect your screen size every time it needs to print certain
352 potentially long strings (this doesn’t change the behavior of
352 potentially long strings (this doesn’t change the behavior of
353 the ’print’ keyword, it’s only triggered internally). If for
353 the ’print’ keyword, it’s only triggered internally). If for
354 some reason this isn’t working well (it needs curses support),
354 some reason this isn’t working well (it needs curses support),
355 specify it yourself. Otherwise don’t change the default.
355 specify it yourself. Otherwise don’t change the default.
356
356
357 -separate_in|si <string>
357 -separate_in|si <string>
358 Separator before input prompts. Default ’0.
358 Separator before input prompts. Default ’0.
359
359
360 -separate_out|so <string>
360 -separate_out|so <string>
361 Separator before output prompts. Default: 0 (nothing).
361 Separator before output prompts. Default: 0 (nothing).
362
362
363 -separate_out2|so2 <string>
363 -separate_out2|so2 <string>
364 Separator after output prompts. Default: 0 (nothing).
364 Separator after output prompts. Default: 0 (nothing).
365
365
366 -nosep Shorthand for ’-separate_in 0 -separate_out 0 -separate_out2 0’.
366 -nosep Shorthand for ’-separate_in 0 -separate_out 0 -separate_out2 0’.
367 Simply removes all input/output separators.
367 Simply removes all input/output separators.
368
368
369 -upgrade
369 -upgrade
370 Allows you to upgrade your IPYTHONDIR configuration when you
370 Allows you to upgrade your IPYTHONDIR configuration when you
371 install a new version of IPython. Since new versions may
371 install a new version of IPython. Since new versions may
372 include new command lines options or example files, this copies
372 include new command lines options or example files, this copies
373 updated ipythonrc-type files. However, it backs up (with a .old
373 updated ipythonrc-type files. However, it backs up (with a .old
374 extension) all files which it overwrites so that you can merge
374 extension) all files which it overwrites so that you can merge
375 back any custimizations you might have in your personal files.
375 back any custimizations you might have in your personal files.
376
376
377 -Version
377 -Version
378 Print version information and exit.
378 Print version information and exit.
379
379
380 -xmode <modename>
380 -xmode <modename>
381 Mode for exception reporting. The valid modes are Plain, Con-
381 Mode for exception reporting. The valid modes are Plain, Con-
382 text, and Verbose.
382 text, and Verbose.
383
383
384 - Plain: similar to python’s normal traceback printing.
384 - Plain: similar to python’s normal traceback printing.
385
385
386 - Context: prints 5 lines of context source code around each
386 - Context: prints 5 lines of context source code around each
387 line in the traceback.
387 line in the traceback.
388
388
389 - Verbose: similar to Context, but additionally prints the vari-
389 - Verbose: similar to Context, but additionally prints the vari-
390 ables currently visible where the exception happened (shortening
390 ables currently visible where the exception happened (shortening
391 their strings if too long). This can potentially be very slow,
391 their strings if too long). This can potentially be very slow,
392 if you happen to have a huge data structure whose string repre-
392 if you happen to have a huge data structure whose string repre-
393 sentation is complex to compute. Your computer may appear to
393 sentation is complex to compute. Your computer may appear to
394 freeze for a while with cpu usage at 100%. If this occurs, you
394 freeze for a while with cpu usage at 100%. If this occurs, you
395 can cancel the traceback with Ctrl-C (maybe hitting it more than
395 can cancel the traceback with Ctrl-C (maybe hitting it more than
396 once).
396 once).
397
397
398
398
399 EMBEDDING
399 EMBEDDING
400 It is possible to start an IPython instance inside your own Python pro-
400 It is possible to start an IPython instance inside your own Python pro-
401 grams. In the documentation example files there are some illustrations
401 grams. In the documentation example files there are some illustrations
402 on how to do this.
402 on how to do this.
403
403
404 This feature allows you to evalutate dynamically the state of your
404 This feature allows you to evalutate dynamically the state of your
405 code, operate with your variables, analyze them, etc. Note however
405 code, operate with your variables, analyze them, etc. Note however
406 that any changes you make to values while in the shell do NOT propagate
406 that any changes you make to values while in the shell do NOT propagate
407 back to the running code, so it is safe to modify your values because
407 back to the running code, so it is safe to modify your values because
408 you won’t break your code in bizarre ways by doing so.
408 you won’t break your code in bizarre ways by doing so.
409 """
409 """
410
410
411 cmd_line_usage = __doc__
411 cmd_line_usage = __doc__
412
412
413 #---------------------------------------------------------------------------
413 #---------------------------------------------------------------------------
414 interactive_usage = """
414 interactive_usage = """
415 IPython -- An enhanced Interactive Python
415 IPython -- An enhanced Interactive Python
416 =========================================
416 =========================================
417
417
418 IPython offers a combination of convenient shell features, special commands
418 IPython offers a combination of convenient shell features, special commands
419 and a history mechanism for both input (command history) and output (results
419 and a history mechanism for both input (command history) and output (results
420 caching, similar to Mathematica). It is intended to be a fully compatible
420 caching, similar to Mathematica). It is intended to be a fully compatible
421 replacement for the standard Python interpreter, while offering vastly
421 replacement for the standard Python interpreter, while offering vastly
422 improved functionality and flexibility.
422 improved functionality and flexibility.
423
423
424 At your system command line, type 'ipython -help' to see the command line
424 At your system command line, type 'ipython -help' to see the command line
425 options available. This document only describes interactive features.
425 options available. This document only describes interactive features.
426
426
427 Warning: IPython relies on the existence of a global variable called __IP which
427 Warning: IPython relies on the existence of a global variable called __IP which
428 controls the shell itself. If you redefine __IP to anything, bizarre behavior
428 controls the shell itself. If you redefine __IP to anything, bizarre behavior
429 will quickly occur.
429 will quickly occur.
430
430
431 MAIN FEATURES
431 MAIN FEATURES
432
432
433 * Access to the standard Python help. As of Python 2.1, a help system is
433 * Access to the standard Python help. As of Python 2.1, a help system is
434 available with access to object docstrings and the Python manuals. Simply
434 available with access to object docstrings and the Python manuals. Simply
435 type 'help' (no quotes) to access it.
435 type 'help' (no quotes) to access it.
436
436
437 * Magic commands: type %magic for information on the magic subsystem.
437 * Magic commands: type %magic for information on the magic subsystem.
438
438
439 * System command aliases, via the %alias command or the ipythonrc config file.
439 * System command aliases, via the %alias command or the ipythonrc config file.
440
440
441 * Dynamic object information:
441 * Dynamic object information:
442
442
443 Typing ?word or word? prints detailed information about an object. If
443 Typing ?word or word? prints detailed information about an object. If
444 certain strings in the object are too long (docstrings, code, etc.) they get
444 certain strings in the object are too long (docstrings, code, etc.) they get
445 snipped in the center for brevity.
445 snipped in the center for brevity.
446
446
447 Typing ??word or word?? gives access to the full information without
447 Typing ??word or word?? gives access to the full information without
448 snipping long strings. Long strings are sent to the screen through the less
448 snipping long strings. Long strings are sent to the screen through the less
449 pager if longer than the screen, printed otherwise.
449 pager if longer than the screen, printed otherwise.
450
450
451 The ?/?? system gives access to the full source code for any object (if
451 The ?/?? system gives access to the full source code for any object (if
452 available), shows function prototypes and other useful information.
452 available), shows function prototypes and other useful information.
453
453
454 If you just want to see an object's docstring, type '%pdoc object' (without
454 If you just want to see an object's docstring, type '%pdoc object' (without
455 quotes, and without % if you have automagic on).
455 quotes, and without % if you have automagic on).
456
456
457 Both %pdoc and ?/?? give you access to documentation even on things which are
457 Both %pdoc and ?/?? give you access to documentation even on things which are
458 not explicitely defined. Try for example typing {}.get? or after import os,
458 not explicitely defined. Try for example typing {}.get? or after import os,
459 type os.path.abspath??. The magic functions %pdef, %source and %file operate
459 type os.path.abspath??. The magic functions %pdef, %source and %file operate
460 similarly.
460 similarly.
461
461
462 * Completion in the local namespace, by typing TAB at the prompt.
462 * Completion in the local namespace, by typing TAB at the prompt.
463
463
464 At any time, hitting tab will complete any available python commands or
464 At any time, hitting tab will complete any available python commands or
465 variable names, and show you a list of the possible completions if there's
465 variable names, and show you a list of the possible completions if there's
466 no unambiguous one. It will also complete filenames in the current directory.
466 no unambiguous one. It will also complete filenames in the current directory.
467
467
468 This feature requires the readline and rlcomplete modules, so it won't work
468 This feature requires the readline and rlcomplete modules, so it won't work
469 if your Python lacks readline support (such as under Windows).
469 if your Python lacks readline support (such as under Windows).
470
470
471 * Search previous command history in two ways (also requires readline):
471 * Search previous command history in two ways (also requires readline):
472
472
473 - Start typing, and then use Ctrl-p (previous,up) and Ctrl-n (next,down) to
473 - Start typing, and then use Ctrl-p (previous,up) and Ctrl-n (next,down) to
474 search through only the history items that match what you've typed so
474 search through only the history items that match what you've typed so
475 far. If you use Ctrl-p/Ctrl-n at a blank prompt, they just behave like
475 far. If you use Ctrl-p/Ctrl-n at a blank prompt, they just behave like
476 normal arrow keys.
476 normal arrow keys.
477
477
478 - Hit Ctrl-r: opens a search prompt. Begin typing and the system searches
478 - Hit Ctrl-r: opens a search prompt. Begin typing and the system searches
479 your history for lines that match what you've typed so far, completing as
479 your history for lines that match what you've typed so far, completing as
480 much as it can.
480 much as it can.
481
481
482 * Persistent command history across sessions (readline required).
482 * Persistent command history across sessions (readline required).
483
483
484 * Logging of input with the ability to save and restore a working session.
484 * Logging of input with the ability to save and restore a working session.
485
485
486 * System escape with !. Typing !ls will run 'ls' in the current directory.
486 * System escape with !. Typing !ls will run 'ls' in the current directory.
487
487
488 * The reload command does a 'deep' reload of a module: changes made to the
488 * The reload command does a 'deep' reload of a module: changes made to the
489 module since you imported will actually be available without having to exit.
489 module since you imported will actually be available without having to exit.
490
490
491 * Verbose and colored exception traceback printouts. See the magic xmode and
491 * Verbose and colored exception traceback printouts. See the magic xmode and
492 xcolor functions for details (just type %magic).
492 xcolor functions for details (just type %magic).
493
493
494 * Input caching system:
494 * Input caching system:
495
495
496 IPython offers numbered prompts (In/Out) with input and output caching. All
496 IPython offers numbered prompts (In/Out) with input and output caching. All
497 input is saved and can be retrieved as variables (besides the usual arrow
497 input is saved and can be retrieved as variables (besides the usual arrow
498 key recall).
498 key recall).
499
499
500 The following GLOBAL variables always exist (so don't overwrite them!):
500 The following GLOBAL variables always exist (so don't overwrite them!):
501 _i: stores previous input.
501 _i: stores previous input.
502 _ii: next previous.
502 _ii: next previous.
503 _iii: next-next previous.
503 _iii: next-next previous.
504 _ih : a list of all input _ih[n] is the input from line n.
504 _ih : a list of all input _ih[n] is the input from line n.
505
505
506 Additionally, global variables named _i<n> are dynamically created (<n>
506 Additionally, global variables named _i<n> are dynamically created (<n>
507 being the prompt counter), such that _i<n> == _ih[<n>]
507 being the prompt counter), such that _i<n> == _ih[<n>]
508
508
509 For example, what you typed at prompt 14 is available as _i14 and _ih[14].
509 For example, what you typed at prompt 14 is available as _i14 and _ih[14].
510
510
511 You can create macros which contain multiple input lines from this history,
511 You can create macros which contain multiple input lines from this history,
512 for later re-execution, with the %macro function.
512 for later re-execution, with the %macro function.
513
513
514 The history function %hist allows you to see any part of your input history
514 The history function %hist allows you to see any part of your input history
515 by printing a range of the _i variables. Note that inputs which contain
515 by printing a range of the _i variables. Note that inputs which contain
516 magic functions (%) appear in the history with a prepended comment. This is
516 magic functions (%) appear in the history with a prepended comment. This is
517 because they aren't really valid Python code, so you can't exec them.
517 because they aren't really valid Python code, so you can't exec them.
518
518
519 * Output caching system:
519 * Output caching system:
520
520
521 For output that is returned from actions, a system similar to the input
521 For output that is returned from actions, a system similar to the input
522 cache exists but using _ instead of _i. Only actions that produce a result
522 cache exists but using _ instead of _i. Only actions that produce a result
523 (NOT assignments, for example) are cached. If you are familiar with
523 (NOT assignments, for example) are cached. If you are familiar with
524 Mathematica, IPython's _ variables behave exactly like Mathematica's %
524 Mathematica, IPython's _ variables behave exactly like Mathematica's %
525 variables.
525 variables.
526
526
527 The following GLOBAL variables always exist (so don't overwrite them!):
527 The following GLOBAL variables always exist (so don't overwrite them!):
528 _ (one underscore): previous output.
528 _ (one underscore): previous output.
529 __ (two underscores): next previous.
529 __ (two underscores): next previous.
530 ___ (three underscores): next-next previous.
530 ___ (three underscores): next-next previous.
531
531
532 Global variables named _<n> are dynamically created (<n> being the prompt
532 Global variables named _<n> are dynamically created (<n> being the prompt
533 counter), such that the result of output <n> is always available as _<n>.
533 counter), such that the result of output <n> is always available as _<n>.
534
534
535 Finally, a global dictionary named _oh exists with entries for all lines
535 Finally, a global dictionary named _oh exists with entries for all lines
536 which generated output.
536 which generated output.
537
537
538 * Directory history:
538 * Directory history:
539
539
540 Your history of visited directories is kept in the global list _dh, and the
540 Your history of visited directories is kept in the global list _dh, and the
541 magic %cd command can be used to go to any entry in that list.
541 magic %cd command can be used to go to any entry in that list.
542
542
543 * Auto-parentheses and auto-quotes (adapted from Nathan Gray's LazyPython)
543 * Auto-parentheses and auto-quotes (adapted from Nathan Gray's LazyPython)
544
544
545 1. Auto-parentheses
545 1. Auto-parentheses
546 Callable objects (i.e. functions, methods, etc) can be invoked like
546 Callable objects (i.e. functions, methods, etc) can be invoked like
547 this (notice the commas between the arguments):
547 this (notice the commas between the arguments):
548 >>> callable_ob arg1, arg2, arg3
548 >>> callable_ob arg1, arg2, arg3
549 and the input will be translated to this:
549 and the input will be translated to this:
550 --> callable_ob(arg1, arg2, arg3)
550 --> callable_ob(arg1, arg2, arg3)
551 You can force auto-parentheses by using '/' as the first character
551 You can force auto-parentheses by using '/' as the first character
552 of a line. For example:
552 of a line. For example:
553 >>> /globals # becomes 'globals()'
553 >>> /globals # becomes 'globals()'
554 Note that the '/' MUST be the first character on the line! This
554 Note that the '/' MUST be the first character on the line! This
555 won't work:
555 won't work:
556 >>> print /globals # syntax error
556 >>> print /globals # syntax error
557
557
558 In most cases the automatic algorithm should work, so you should
558 In most cases the automatic algorithm should work, so you should
559 rarely need to explicitly invoke /. One notable exception is if you
559 rarely need to explicitly invoke /. One notable exception is if you
560 are trying to call a function with a list of tuples as arguments (the
560 are trying to call a function with a list of tuples as arguments (the
561 parenthesis will confuse IPython):
561 parenthesis will confuse IPython):
562 In [1]: zip (1,2,3),(4,5,6) # won't work
562 In [1]: zip (1,2,3),(4,5,6) # won't work
563 but this will work:
563 but this will work:
564 In [2]: /zip (1,2,3),(4,5,6)
564 In [2]: /zip (1,2,3),(4,5,6)
565 ------> zip ((1,2,3),(4,5,6))
565 ------> zip ((1,2,3),(4,5,6))
566 Out[2]= [(1, 4), (2, 5), (3, 6)]
566 Out[2]= [(1, 4), (2, 5), (3, 6)]
567
567
568 IPython tells you that it has altered your command line by
568 IPython tells you that it has altered your command line by
569 displaying the new command line preceded by -->. e.g.:
569 displaying the new command line preceded by -->. e.g.:
570 In [18]: callable list
570 In [18]: callable list
571 -------> callable (list)
571 -------> callable (list)
572
572
573 2. Auto-Quoting
573 2. Auto-Quoting
574 You can force auto-quoting of a function's arguments by using ',' as
574 You can force auto-quoting of a function's arguments by using ',' as
575 the first character of a line. For example:
575 the first character of a line. For example:
576 >>> ,my_function /home/me # becomes my_function("/home/me")
576 >>> ,my_function /home/me # becomes my_function("/home/me")
577
577
578 If you use ';' instead, the whole argument is quoted as a single
578 If you use ';' instead, the whole argument is quoted as a single
579 string (while ',' splits on whitespace):
579 string (while ',' splits on whitespace):
580 >>> ,my_function a b c # becomes my_function("a","b","c")
580 >>> ,my_function a b c # becomes my_function("a","b","c")
581 >>> ;my_function a b c # becomes my_function("a b c")
581 >>> ;my_function a b c # becomes my_function("a b c")
582
582
583 Note that the ',' MUST be the first character on the line! This
583 Note that the ',' MUST be the first character on the line! This
584 won't work:
584 won't work:
585 >>> x = ,my_function /home/me # syntax error
585 >>> x = ,my_function /home/me # syntax error
586 """
586 """
@@ -1,392 +1,392 b''
1 .\" Hey, EMACS: -*- nroff -*-
1 .\" Hey, EMACS: -*- nroff -*-
2 .\" First parameter, NAME, should be all caps
2 .\" First parameter, NAME, should be all caps
3 .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
3 .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
4 .\" other parameters are allowed: see man(7), man(1)
4 .\" other parameters are allowed: see man(7), man(1)
5 .TH IPYTHON 1 "November 30, 2004"
5 .TH IPYTHON 1 "November 30, 2004"
6 .\" Please adjust this date whenever revising the manpage.
6 .\" Please adjust this date whenever revising the manpage.
7 .\"
7 .\"
8 .\" Some roff macros, for reference:
8 .\" Some roff macros, for reference:
9 .\" .nh disable hyphenation
9 .\" .nh disable hyphenation
10 .\" .hy enable hyphenation
10 .\" .hy enable hyphenation
11 .\" .ad l left justify
11 .\" .ad l left justify
12 .\" .ad b justify to both left and right margins
12 .\" .ad b justify to both left and right margins
13 .\" .nf disable filling
13 .\" .nf disable filling
14 .\" .fi enable filling
14 .\" .fi enable filling
15 .\" .br insert line break
15 .\" .br insert line break
16 .\" .sp <n> insert n+1 empty lines
16 .\" .sp <n> insert n+1 empty lines
17 .\" for manpage-specific macros, see man(7) and groff_man(7)
17 .\" for manpage-specific macros, see man(7) and groff_man(7)
18 .\" .SH section heading
18 .\" .SH section heading
19 .\" .SS secondary section heading
19 .\" .SS secondary section heading
20 .\"
20 .\"
21 .\"
21 .\"
22 .\" To preview this page as plain text: nroff -man ipython.1
22 .\" To preview this page as plain text: nroff -man ipython.1
23 .\"
23 .\"
24 .SH NAME
24 .SH NAME
25 ipython \- An Enhanced Interactive Python
25 ipython \- An Enhanced Interactive Python
26 .SH SYNOPSIS
26 .SH SYNOPSIS
27 .B ipython
27 .B ipython
28 .RI [ options ] " files" ...
28 .RI [ options ] " files" ...
29 .SH DESCRIPTION
29 .SH DESCRIPTION
30 An interactive Python shell with automatic history (input and output),
30 An interactive Python shell with automatic history (input and output),
31 dynamic object introspection, easier configuration, command
31 dynamic object introspection, easier configuration, command
32 completion, access to the system shell, integration with numerical and
32 completion, access to the system shell, integration with numerical and
33 scientific computing tools, and more.
33 scientific computing tools, and more.
34 .SH SPECIAL THREADING OPTIONS
34 .SH SPECIAL THREADING OPTIONS
35 The following special options are ONLY valid at the beginning of the command
35 The following special options are ONLY valid at the beginning of the command
36 line, and not later. This is because they control the initialization of
36 line, and not later. This is because they control the initialization of
37 ipython itself, before the normal option-handling mechanism is active.
37 ipython itself, before the normal option-handling mechanism is active.
38 .TP
38 .TP
39 .B \-gthread, \-qthread, \-wthread, \-pylab
39 .B \-gthread, \-qthread, \-wthread, \-pylab
40 Only ONE of these can be given, and it can only be given as the first option
40 Only ONE of these can be given, and it can only be given as the first option
41 passed to IPython (it will have no effect in any other position). They
41 passed to IPython (it will have no effect in any other position). They
42 provide threading support for the GTK, QT and WXWidgets toolkits, and for the
42 provide threading support for the GTK, QT and WXWidgets toolkits, and for the
43 matplotlib library.
43 matplotlib library.
44 .br
44 .br
45 .sp 1
45 .sp 1
46 With any of the first three options, IPython starts running a separate thread
46 With any of the first three options, IPython starts running a separate thread
47 for the graphical toolkit's operation, so that you can open and control
47 for the graphical toolkit's operation, so that you can open and control
48 graphical elements from within an IPython command line, without blocking. All
48 graphical elements from within an IPython command line, without blocking. All
49 three provide essentially the same functionality, respectively for GTK, QT and
49 three provide essentially the same functionality, respectively for GTK, QT and
50 WXWidgets (via their Python interfaces).
50 WXWidgets (via their Python interfaces).
51 .br
51 .br
52 .sp 1
52 .sp 1
53 If \-pylab is given, IPython loads special support for the matplotlib library
53 If \-pylab is given, IPython loads special support for the matplotlib library
54 (http://matplotlib.sourceforge.net), allowing interactive usage of any of its
54 (http://matplotlib.sourceforge.net), allowing interactive usage of any of its
55 backends as defined in the user's .matplotlibrc file. It automatically
55 backends as defined in the user's .matplotlibrc file. It automatically
56 activates GTK, QT or WX threading for IPyhton if the choice of matplotlib
56 activates GTK, QT or WX threading for IPyhton if the choice of matplotlib
57 backend requires it. It also modifies the %run command to correctly execute
57 backend requires it. It also modifies the %run command to correctly execute
58 (without blocking) any matplotlib-based script which calls show() at the end.
58 (without blocking) any matplotlib-based script which calls show() at the end.
59 .TP
59 .TP
60 .B \-tk
60 .B \-tk
61 The \-g/q/wthread options, and \-pylab (if matplotlib is configured to use
61 The \-g/q/wthread options, and \-pylab (if matplotlib is configured to use
62 GTK, QT or WX), will normally block Tk graphical interfaces. This means that
62 GTK, QT or WX), will normally block Tk graphical interfaces. This means that
63 when GTK, QT or WX threading is active, any attempt to open a Tk GUI will
63 when GTK, QT or WX threading is active, any attempt to open a Tk GUI will
64 result in a dead window, and possibly cause the Python interpreter to crash.
64 result in a dead window, and possibly cause the Python interpreter to crash.
65 An extra option, \-tk, is available to address this issue. It can ONLY be
65 An extra option, \-tk, is available to address this issue. It can ONLY be
66 given as a SECOND option after any of the above (\-gthread, \-qthread,
66 given as a SECOND option after any of the above (\-gthread, \-qthread,
67 \-wthread or \-pylab).
67 \-wthread or \-pylab).
68 .br
68 .br
69 .sp 1
69 .sp 1
70 If \-tk is given, IPython will try to coordinate Tk threading with GTK, QT or
70 If \-tk is given, IPython will try to coordinate Tk threading with GTK, QT or
71 WX. This is however potentially unreliable, and you will have to test on your
71 WX. This is however potentially unreliable, and you will have to test on your
72 platform and Python configuration to determine whether it works for you.
72 platform and Python configuration to determine whether it works for you.
73 Debian users have reported success, apparently due to the fact that Debian
73 Debian users have reported success, apparently due to the fact that Debian
74 builds all of Tcl, Tk, Tkinter and Python with pthreads support. Under other
74 builds all of Tcl, Tk, Tkinter and Python with pthreads support. Under other
75 Linux environments (such as Fedora Core 2), this option has caused random
75 Linux environments (such as Fedora Core 2), this option has caused random
76 crashes and lockups of the Python interpreter. Under other operating systems
76 crashes and lockups of the Python interpreter. Under other operating systems
77 (Mac OSX and Windows), you'll need to try it to find out, since currently no
77 (Mac OSX and Windows), you'll need to try it to find out, since currently no
78 user reports are available.
78 user reports are available.
79 .br
79 .br
80 .sp 1
80 .sp 1
81 There is unfortunately no way for IPython to determine at runtime whether \-tk
81 There is unfortunately no way for IPython to determine at runtime whether \-tk
82 will work reliably or not, so you will need to do some experiments before
82 will work reliably or not, so you will need to do some experiments before
83 relying on it for regular work.
83 relying on it for regular work.
84 .
84 .
85 .SS A WARNING ABOUT SIGNALS AND THREADS
85 .SS A WARNING ABOUT SIGNALS AND THREADS
86 When any of the thread systems (GTK, QT or WX) are active, either directly or
86 When any of the thread systems (GTK, QT or WX) are active, either directly or
87 via \-pylab with a threaded backend, it is impossible to interrupt
87 via \-pylab with a threaded backend, it is impossible to interrupt
88 long-running Python code via Ctrl\-C. IPython can not pass the
88 long-running Python code via Ctrl\-C. IPython can not pass the
89 KeyboardInterrupt exception (or the underlying SIGINT) across threads, so any
89 KeyboardInterrupt exception (or the underlying SIGINT) across threads, so any
90 long-running process started from IPython will run to completion, or will have
90 long-running process started from IPython will run to completion, or will have
91 to be killed via an external (OS-based) mechanism.
91 to be killed via an external (OS-based) mechanism.
92 .br
92 .br
93 .sp 1
93 .sp 1
94 To the best of my knowledge, this limitation is imposed by the Python
94 To the best of my knowledge, this limitation is imposed by the Python
95 interpreter itself, and it comes from the difficulty of writing portable
95 interpreter itself, and it comes from the difficulty of writing portable
96 signal/threaded code. If any user is an expert on this topic and can suggest
96 signal/threaded code. If any user is an expert on this topic and can suggest
97 a better solution, I would love to hear about it. In the IPython sources,
97 a better solution, I would love to hear about it. In the IPython sources,
98 look at the Shell.py module, and in particular at the runcode() method.
98 look at the Shell.py module, and in particular at the runcode() method.
99 .
99 .
100 .SH REGULAR OPTIONS
100 .SH REGULAR OPTIONS
101 After the above threading options have been given, regular options can follow
101 After the above threading options have been given, regular options can follow
102 in any order. All options can be abbreviated to their shortest non-ambiguous
102 in any order. All options can be abbreviated to their shortest non-ambiguous
103 form and are case-sensitive. One or two dashes can be used. Some options
103 form and are case-sensitive. One or two dashes can be used. Some options
104 have an alternate short form, indicated after a |.
104 have an alternate short form, indicated after a |.
105 .br
105 .br
106 .sp 1
106 .sp 1
107 Most options can also be set from your ipythonrc configuration file.
107 Most options can also be set from your ipythonrc configuration file.
108 See the provided examples for assistance. Options given on the
108 See the provided examples for assistance. Options given on the
109 commandline override the values set in the ipythonrc file.
109 commandline override the values set in the ipythonrc file.
110 .br
110 .br
111 .sp 1
111 .sp 1
112 All options with a no| prepended can be specified in 'no' form
112 All options with a [no] prepended can be specified in negated form
113 (\-nooption instead of \-option) to turn the feature off.
113 (\-nooption instead of \-option) to turn the feature off.
114 .TP
114 .TP
115 .B \-h, \-\-help
115 .B \-h, \-\-help
116 Show summary of options.
116 Show summary of options.
117 .TP
117 .TP
118 .B \-no|autocall
118 .B \-[no]autocall
119 Make IPython automatically call any callable object even if you didn't type
119 Make IPython automatically call any callable object even if you didn't type
120 explicit parentheses. For example, 'str 43' becomes 'str(43)' automatically.
120 explicit parentheses. For example, 'str 43' becomes 'str(43)' automatically.
121 .TP
121 .TP
122 .B \-no|autoindent
122 .B \-[no]autoindent
123 Turn automatic indentation on/off.
123 Turn automatic indentation on/off.
124 .TP
124 .TP
125 .B \-no|automagic
125 .B \-[no]automagic
126 Make magic commands automatic (without needing their first character
126 Make magic commands automatic (without needing their first character
127 to be @). Type @magic at the IPython prompt for more information.
127 to be @). Type @magic at the IPython prompt for more information.
128 .TP
128 .TP
129 .B \-no|autoparens
129 .B \-[no]autoparens
130 Make IPython automatically call any callable object even if you didn't
130 Make IPython automatically call any callable object even if you didn't
131 type explicit parentheses. For example, 'str 43' becomes 'str(43)'
131 type explicit parentheses. For example, 'str 43' becomes 'str(43)'
132 automatically.
132 automatically.
133 .TP
133 .TP
134 .B \-no|banner
134 .B \-[no]banner
135 Print the intial information banner (default on).
135 Print the intial information banner (default on).
136 .TP
136 .TP
137 .B \-c <command>
137 .B \-c <command>
138 Execute the given command string, and set sys.argv to ['c']. This is similar
138 Execute the given command string, and set sys.argv to ['c']. This is similar
139 to the \-c option in the normal Python interpreter.
139 to the \-c option in the normal Python interpreter.
140 .TP
140 .TP
141 .B \-cache_size|cs <n>
141 .B \-cache_size|cs <n>
142 Size of the output cache (maximum number of entries to hold in
142 Size of the output cache (maximum number of entries to hold in
143 memory). The default is 1000, you can change it permanently in your
143 memory). The default is 1000, you can change it permanently in your
144 config file. Setting it to 0 completely disables the caching system,
144 config file. Setting it to 0 completely disables the caching system,
145 and the minimum value accepted is 20 (if you provide a value less than
145 and the minimum value accepted is 20 (if you provide a value less than
146 20, it is reset to 0 and a warning is issued). This limit is defined
146 20, it is reset to 0 and a warning is issued). This limit is defined
147 because otherwise you'll spend more time re-flushing a too small cache
147 because otherwise you'll spend more time re-flushing a too small cache
148 than working.
148 than working.
149 .TP
149 .TP
150 .B \-classic|cl
150 .B \-classic|cl
151 Gives IPython a similar feel to the classic Python prompt.
151 Gives IPython a similar feel to the classic Python prompt.
152 .TP
152 .TP
153 .B \-colors <scheme>
153 .B \-colors <scheme>
154 Color scheme for prompts and exception reporting. Currently
154 Color scheme for prompts and exception reporting. Currently
155 implemented: NoColor, Linux, and LightBG.
155 implemented: NoColor, Linux, and LightBG.
156 .TP
156 .TP
157 .B \-no|color_info
157 .B \-[no]color_info
158 IPython can display information about objects via a set of functions,
158 IPython can display information about objects via a set of functions,
159 and optionally can use colors for this, syntax highlighting source
159 and optionally can use colors for this, syntax highlighting source
160 code and various other elements. However, because this information is
160 code and various other elements. However, because this information is
161 passed through a pager (like 'less') and many pagers get confused with
161 passed through a pager (like 'less') and many pagers get confused with
162 color codes, this option is off by default. You can test it and turn
162 color codes, this option is off by default. You can test it and turn
163 it on permanently in your ipythonrc file if it works for you. As a
163 it on permanently in your ipythonrc file if it works for you. As a
164 reference, the 'less' pager supplied with Mandrake 8.2 works ok, but
164 reference, the 'less' pager supplied with Mandrake 8.2 works ok, but
165 that in RedHat 7.2 doesn't.
165 that in RedHat 7.2 doesn't.
166 .br
166 .br
167 .sp 1
167 .sp 1
168 Test it and turn it on permanently if it works with your system. The
168 Test it and turn it on permanently if it works with your system. The
169 magic function @color_info allows you to toggle this interactively for
169 magic function @color_info allows you to toggle this interactively for
170 testing.
170 testing.
171 .TP
171 .TP
172 .B \-no|confirm_exit
172 .B \-[no]confirm_exit
173 Set to confirm when you try to exit IPython with an EOF (Control-D in
173 Set to confirm when you try to exit IPython with an EOF (Control-D in
174 Unix, Control-Z/Enter in Windows). Note that using the magic functions
174 Unix, Control-Z/Enter in Windows). Note that using the magic functions
175 @Exit or @Quit you can force a direct exit, bypassing any
175 @Exit or @Quit you can force a direct exit, bypassing any
176 confirmation.
176 confirmation.
177 .TP
177 .TP
178 .B \-no|debug
178 .B \-[no]debug
179 Show information about the loading process. Very useful to pin down
179 Show information about the loading process. Very useful to pin down
180 problems with your configuration files or to get details about session
180 problems with your configuration files or to get details about session
181 restores.
181 restores.
182 .TP
182 .TP
183 .B \-no|deep_reload
183 .B \-[no]deep_reload
184 IPython can use the deep_reload module which reloads changes in
184 IPython can use the deep_reload module which reloads changes in
185 modules recursively (it replaces the reload() function, so you don't
185 modules recursively (it replaces the reload() function, so you don't
186 need to change anything to use it). deep_reload() forces a full reload
186 need to change anything to use it). deep_reload() forces a full reload
187 of modules whose code may have changed, which the default reload()
187 of modules whose code may have changed, which the default reload()
188 function does not.
188 function does not.
189 .br
189 .br
190 .sp 1
190 .sp 1
191 When deep_reload is off, IPython will use the normal reload(), but
191 When deep_reload is off, IPython will use the normal reload(), but
192 deep_reload will still be available as dreload(). This feature is off
192 deep_reload will still be available as dreload(). This feature is off
193 by default [which means that you have both normal reload() and
193 by default [which means that you have both normal reload() and
194 dreload()].
194 dreload()].
195 .TP
195 .TP
196 .B \-editor <name>
196 .B \-editor <name>
197 Which editor to use with the @edit command. By default, IPython will
197 Which editor to use with the @edit command. By default, IPython will
198 honor your EDITOR environment variable (if not set, vi is the Unix
198 honor your EDITOR environment variable (if not set, vi is the Unix
199 default and notepad the Windows one). Since this editor is invoked on
199 default and notepad the Windows one). Since this editor is invoked on
200 the fly by IPython and is meant for editing small code snippets, you
200 the fly by IPython and is meant for editing small code snippets, you
201 may want to use a small, lightweight editor here (in case your default
201 may want to use a small, lightweight editor here (in case your default
202 EDITOR is something like Emacs).
202 EDITOR is something like Emacs).
203 .TP
203 .TP
204 .B \-ipythondir <name>
204 .B \-ipythondir <name>
205 The name of your IPython configuration directory IPYTHONDIR. This can
205 The name of your IPython configuration directory IPYTHONDIR. This can
206 also be specified through the environment variable IPYTHONDIR.
206 also be specified through the environment variable IPYTHONDIR.
207 .TP
207 .TP
208 .B \-log|l
208 .B \-log|l
209 Generate a log file of all input. The file is named ipython.log in
209 Generate a log file of all input. The file is named ipython.log in
210 your current directory (which prevents logs from multiple IPython
210 your current directory (which prevents logs from multiple IPython
211 sessions from trampling each other). You can use this to later restore
211 sessions from trampling each other). You can use this to later restore
212 a session by loading your logfile as a file to be executed with option
212 a session by loading your logfile as a file to be executed with option
213 -logplay (see below).
213 -logplay (see below).
214 .TP
214 .TP
215 .B \-logfile|lf
215 .B \-logfile|lf
216 Specifu the name of your logfile.
216 Specifu the name of your logfile.
217 .TP
217 .TP
218 .B \-logplay|lp
218 .B \-logplay|lp
219 Replay a previous log. For restoring a session as close as possible to
219 Replay a previous log. For restoring a session as close as possible to
220 the state you left it in, use this option (don't just run the
220 the state you left it in, use this option (don't just run the
221 logfile). With \-logplay, IPython will try to reconstruct the previous
221 logfile). With \-logplay, IPython will try to reconstruct the previous
222 working environment in full, not just execute the commands in the
222 working environment in full, not just execute the commands in the
223 logfile.
223 logfile.
224 .br
224 .br
225 .sh 1
225 .sh 1
226 When a session is restored, logging is automatically turned on again
226 When a session is restored, logging is automatically turned on again
227 with the name of the logfile it was invoked with (it is read from the
227 with the name of the logfile it was invoked with (it is read from the
228 log header). So once you've turned logging on for a session, you can
228 log header). So once you've turned logging on for a session, you can
229 quit IPython and reload it as many times as you want and it will
229 quit IPython and reload it as many times as you want and it will
230 continue to log its history and restore from the beginning every time.
230 continue to log its history and restore from the beginning every time.
231 .br
231 .br
232 .sp 1
232 .sp 1
233 Caveats: there are limitations in this option. The history variables
233 Caveats: there are limitations in this option. The history variables
234 _i*,_* and _dh don't get restored properly. In the future we will try
234 _i*,_* and _dh don't get restored properly. In the future we will try
235 to implement full session saving by writing and retrieving a
235 to implement full session saving by writing and retrieving a
236 'snapshot' of the memory state of IPython. But our first attempts
236 'snapshot' of the memory state of IPython. But our first attempts
237 failed because of inherent limitations of Python's Pickle module, so
237 failed because of inherent limitations of Python's Pickle module, so
238 this may have to wait.
238 this may have to wait.
239 .TP
239 .TP
240 .B \-no|messages
240 .B \-[no]messages
241 Print messages which IPython collects about its startup process
241 Print messages which IPython collects about its startup process
242 (default on).
242 (default on).
243 .TP
243 .TP
244 .B \-no|pdb
244 .B \-[no]pdb
245 Automatically call the pdb debugger after every uncaught exception. If
245 Automatically call the pdb debugger after every uncaught exception. If
246 you are used to debugging using pdb, this puts you automatically
246 you are used to debugging using pdb, this puts you automatically
247 inside of it after any call (either in IPython or in code called by
247 inside of it after any call (either in IPython or in code called by
248 it) which triggers an exception which goes uncaught.
248 it) which triggers an exception which goes uncaught.
249 .TP
249 .TP
250 .B \-no|pprint
250 .B \-[no]pprint
251 IPython can optionally use the pprint (pretty printer) module for
251 IPython can optionally use the pprint (pretty printer) module for
252 displaying results. pprint tends to give a nicer display of nested
252 displaying results. pprint tends to give a nicer display of nested
253 data structures. If you like it, you can turn it on permanently in
253 data structures. If you like it, you can turn it on permanently in
254 your config file (default off).
254 your config file (default off).
255 .TP
255 .TP
256 .B \-profile|p <name>
256 .B \-profile|p <name>
257 Assume that your config file is ipythonrc-<name> (looks in current dir
257 Assume that your config file is ipythonrc-<name> (looks in current dir
258 first, then in IPYTHONDIR). This is a quick way to keep and load
258 first, then in IPYTHONDIR). This is a quick way to keep and load
259 multiple config files for different tasks, especially if you use the
259 multiple config files for different tasks, especially if you use the
260 include option of config files. You can keep a basic
260 include option of config files. You can keep a basic
261 IPYTHONDIR/ipythonrc file and then have other 'profiles' which include
261 IPYTHONDIR/ipythonrc file and then have other 'profiles' which include
262 this one and load extra things for particular tasks. For example:
262 this one and load extra things for particular tasks. For example:
263 .br
263 .br
264 .sp 1
264 .sp 1
265 1) $HOME/.ipython/ipythonrc : load basic things you always want.
265 1) $HOME/.ipython/ipythonrc : load basic things you always want.
266 .br
266 .br
267 2) $HOME/.ipython/ipythonrc-math : load (1) and basic math-related
267 2) $HOME/.ipython/ipythonrc-math : load (1) and basic math-related
268 modules.
268 modules.
269 .br
269 .br
270 3) $HOME/.ipython/ipythonrc-numeric : load (1) and Numeric and
270 3) $HOME/.ipython/ipythonrc-numeric : load (1) and Numeric and
271 plotting modules.
271 plotting modules.
272 .br
272 .br
273 .sp 1
273 .sp 1
274 Since it is possible to create an endless loop by having circular file
274 Since it is possible to create an endless loop by having circular file
275 inclusions, IPython will stop if it reaches 15 recursive inclusions.
275 inclusions, IPython will stop if it reaches 15 recursive inclusions.
276 .TP
276 .TP
277 .B \-prompt_in1|pi1 <string>
277 .B \-prompt_in1|pi1 <string>
278 Specify the string used for input prompts. Note that if you are using
278 Specify the string used for input prompts. Note that if you are using
279 numbered prompts, the number is represented with a '\\#' in the
279 numbered prompts, the number is represented with a '\\#' in the
280 string. Don't forget to quote strings with spaces embedded in
280 string. Don't forget to quote strings with spaces embedded in
281 them. Default: 'In [\\#]:'.
281 them. Default: 'In [\\#]:'.
282 .br
282 .br
283 .sp 1
283 .sp 1
284 Most bash-like escapes can be used to customize IPython's prompts, as well as
284 Most bash-like escapes can be used to customize IPython's prompts, as well as
285 a few additional ones which are IPython-specific. All valid prompt escapes
285 a few additional ones which are IPython-specific. All valid prompt escapes
286 are described in detail in the Customization section of the IPython HTML/PDF
286 are described in detail in the Customization section of the IPython HTML/PDF
287 manual.
287 manual.
288 .TP
288 .TP
289 .B \-prompt_in2|pi2 <string>
289 .B \-prompt_in2|pi2 <string>
290 Similar to the previous option, but used for the continuation prompts. The
290 Similar to the previous option, but used for the continuation prompts. The
291 special sequence '\\D' is similar to '\\#', but with all digits replaced dots
291 special sequence '\\D' is similar to '\\#', but with all digits replaced dots
292 (so you can have your continuation prompt aligned with your input
292 (so you can have your continuation prompt aligned with your input
293 prompt). Default: ' .\\D.:' (note three spaces at the start for alignment
293 prompt). Default: ' .\\D.:' (note three spaces at the start for alignment
294 with 'In [\\#]').
294 with 'In [\\#]').
295 .TP
295 .TP
296 .B \-prompt_out|po <string>
296 .B \-prompt_out|po <string>
297 String used for output prompts, also uses numbers like prompt_in1.
297 String used for output prompts, also uses numbers like prompt_in1.
298 Default: 'Out[\\#]:'.
298 Default: 'Out[\\#]:'.
299 .TP
299 .TP
300 .B \-quick
300 .B \-quick
301 Start in bare bones mode (no config file loaded).
301 Start in bare bones mode (no config file loaded).
302 .TP
302 .TP
303 .B \-rcfile <name>
303 .B \-rcfile <name>
304 Name of your IPython resource configuration file. normally IPython
304 Name of your IPython resource configuration file. normally IPython
305 loads ipythonrc (from current directory) or IPYTHONDIR/ipythonrc. If
305 loads ipythonrc (from current directory) or IPYTHONDIR/ipythonrc. If
306 the loading of your config file fails, IPython starts with a bare
306 the loading of your config file fails, IPython starts with a bare
307 bones configuration (no modules loaded at all).
307 bones configuration (no modules loaded at all).
308 .TP
308 .TP
309 .B \-no|readline
309 .B \-[no]readline
310 Use the readline library, which is needed to support name completion
310 Use the readline library, which is needed to support name completion
311 and command history, among other things. It is enabled by default, but
311 and command history, among other things. It is enabled by default, but
312 may cause problems for users of X/Emacs in Python comint or shell
312 may cause problems for users of X/Emacs in Python comint or shell
313 buffers.
313 buffers.
314 .br
314 .br
315 .sp 1
315 .sp 1
316 Note that emacs 'eterm' buffers (opened with M-x term) support
316 Note that emacs 'eterm' buffers (opened with M-x term) support
317 IPython's readline and syntax coloring fine, only 'emacs' (M-x shell
317 IPython's readline and syntax coloring fine, only 'emacs' (M-x shell
318 and C-c !) buffers do not.
318 and C-c !) buffers do not.
319 .TP
319 .TP
320 .B \-screen_length|sl <n>
320 .B \-screen_length|sl <n>
321 Number of lines of your screen. This is used to control printing of
321 Number of lines of your screen. This is used to control printing of
322 very long strings. Strings longer than this number of lines will be
322 very long strings. Strings longer than this number of lines will be
323 sent through a pager instead of directly printed.
323 sent through a pager instead of directly printed.
324 .br
324 .br
325 .sp 1
325 .sp 1
326 The default value for this is 0, which means IPython will auto-detect
326 The default value for this is 0, which means IPython will auto-detect
327 your screen size every time it needs to print certain potentially long
327 your screen size every time it needs to print certain potentially long
328 strings (this doesn't change the behavior of the 'print' keyword, it's
328 strings (this doesn't change the behavior of the 'print' keyword, it's
329 only triggered internally). If for some reason this isn't working well
329 only triggered internally). If for some reason this isn't working well
330 (it needs curses support), specify it yourself. Otherwise don't change
330 (it needs curses support), specify it yourself. Otherwise don't change
331 the default.
331 the default.
332 .TP
332 .TP
333 .B \-separate_in|si <string>
333 .B \-separate_in|si <string>
334 Separator before input prompts. Default '\n'.
334 Separator before input prompts. Default '\n'.
335 .TP
335 .TP
336 .B \-separate_out|so <string>
336 .B \-separate_out|so <string>
337 Separator before output prompts. Default: 0 (nothing).
337 Separator before output prompts. Default: 0 (nothing).
338 .TP
338 .TP
339 .B \-separate_out2|so2 <string>
339 .B \-separate_out2|so2 <string>
340 Separator after output prompts. Default: 0 (nothing).
340 Separator after output prompts. Default: 0 (nothing).
341 .TP
341 .TP
342 .B \-nosep
342 .B \-nosep
343 Shorthand for '\-separate_in 0 \-separate_out 0 \-separate_out2 0'.
343 Shorthand for '\-separate_in 0 \-separate_out 0 \-separate_out2 0'.
344 Simply removes all input/output separators.
344 Simply removes all input/output separators.
345 .TP
345 .TP
346 .B \-upgrade
346 .B \-upgrade
347 Allows you to upgrade your IPYTHONDIR configuration when you install a
347 Allows you to upgrade your IPYTHONDIR configuration when you install a
348 new version of IPython. Since new versions may include new command
348 new version of IPython. Since new versions may include new command
349 lines options or example files, this copies updated ipythonrc-type
349 lines options or example files, this copies updated ipythonrc-type
350 files. However, it backs up (with a .old extension) all files which
350 files. However, it backs up (with a .old extension) all files which
351 it overwrites so that you can merge back any custimizations you might
351 it overwrites so that you can merge back any custimizations you might
352 have in your personal files.
352 have in your personal files.
353 .TP
353 .TP
354 .B \-Version
354 .B \-Version
355 Print version information and exit.
355 Print version information and exit.
356 .TP
356 .TP
357 .B \-xmode <modename>
357 .B \-xmode <modename>
358 Mode for exception reporting. The valid modes are Plain, Context, and
358 Mode for exception reporting. The valid modes are Plain, Context, and
359 Verbose.
359 Verbose.
360 .br
360 .br
361 .sp 1
361 .sp 1
362 \- Plain: similar to python's normal traceback printing.
362 \- Plain: similar to python's normal traceback printing.
363 .br
363 .br
364 .sp 1
364 .sp 1
365 \- Context: prints 5 lines of context source code around each line in the
365 \- Context: prints 5 lines of context source code around each line in the
366 traceback.
366 traceback.
367 .br
367 .br
368 .sp 1
368 .sp 1
369 \- Verbose: similar to Context, but additionally prints the variables
369 \- Verbose: similar to Context, but additionally prints the variables
370 currently visible where the exception happened (shortening their strings if
370 currently visible where the exception happened (shortening their strings if
371 too long). This can potentially be very slow, if you happen to have a huge
371 too long). This can potentially be very slow, if you happen to have a huge
372 data structure whose string representation is complex to compute. Your
372 data structure whose string representation is complex to compute. Your
373 computer may appear to freeze for a while with cpu usage at 100%. If this
373 computer may appear to freeze for a while with cpu usage at 100%. If this
374 occurs, you can cancel the traceback with Ctrl-C (maybe hitting it more than
374 occurs, you can cancel the traceback with Ctrl-C (maybe hitting it more than
375 once).
375 once).
376 .
376 .
377 .SH EMBEDDING
377 .SH EMBEDDING
378 It is possible to start an IPython instance inside your own Python
378 It is possible to start an IPython instance inside your own Python
379 programs. In the documentation example files there are some
379 programs. In the documentation example files there are some
380 illustrations on how to do this.
380 illustrations on how to do this.
381 .br
381 .br
382 .sp 1
382 .sp 1
383 This feature allows you to evalutate dynamically the state of your
383 This feature allows you to evalutate dynamically the state of your
384 code, operate with your variables, analyze them, etc. Note however
384 code, operate with your variables, analyze them, etc. Note however
385 that any changes you make to values while in the shell do NOT
385 that any changes you make to values while in the shell do NOT
386 propagate back to the running code, so it is safe to modify your
386 propagate back to the running code, so it is safe to modify your
387 values because you won't break your code in bizarre ways by doing so.
387 values because you won't break your code in bizarre ways by doing so.
388 .SH AUTHOR
388 .SH AUTHOR
389 IPython was written by Fernando Perez <fperez@colorado.edu>, based on earlier
389 IPython was written by Fernando Perez <fperez@colorado.edu>, based on earlier
390 code by Janko Hauser <jh@comunit.de> and Nathaniel Gray
390 code by Janko Hauser <jh@comunit.de> and Nathaniel Gray
391 <n8gray@caltech.edu>. This manual page was written by Jack Moffitt
391 <n8gray@caltech.edu>. This manual page was written by Jack Moffitt
392 <jack@xiph.org>, for the Debian project (but may be used by others).
392 <jack@xiph.org>, for the Debian project (but may be used by others).
@@ -1,9095 +1,9095 b''
1 #LyX 1.3 created this file. For more info see http://www.lyx.org/
1 #LyX 1.3 created this file. For more info see http://www.lyx.org/
2 \lyxformat 221
2 \lyxformat 221
3 \textclass article
3 \textclass article
4 \begin_preamble
4 \begin_preamble
5 %\usepackage{ae,aecompl}
5 %\usepackage{ae,aecompl}
6 \usepackage{color}
6 \usepackage{color}
7
7
8 % A few colors to replace the defaults for certain link types
8 % A few colors to replace the defaults for certain link types
9 \definecolor{orange}{cmyk}{0,0.4,0.8,0.2}
9 \definecolor{orange}{cmyk}{0,0.4,0.8,0.2}
10 \definecolor{darkorange}{rgb}{.71,0.21,0.01}
10 \definecolor{darkorange}{rgb}{.71,0.21,0.01}
11 \definecolor{darkred}{rgb}{.52,0.08,0.01}
11 \definecolor{darkred}{rgb}{.52,0.08,0.01}
12 \definecolor{darkgreen}{rgb}{.12,.54,.11}
12 \definecolor{darkgreen}{rgb}{.12,.54,.11}
13
13
14 % Use and configure listings package for nicely formatted code
14 % Use and configure listings package for nicely formatted code
15 \usepackage{listings}
15 \usepackage{listings}
16 \lstset{
16 \lstset{
17 language=Python,
17 language=Python,
18 basicstyle=\small\ttfamily,
18 basicstyle=\small\ttfamily,
19 commentstyle=\ttfamily\color{blue},
19 commentstyle=\ttfamily\color{blue},
20 stringstyle=\ttfamily\color{darkorange},
20 stringstyle=\ttfamily\color{darkorange},
21 showstringspaces=false,
21 showstringspaces=false,
22 breaklines=true,
22 breaklines=true,
23 postbreak = \space\dots
23 postbreak = \space\dots
24 }
24 }
25
25
26 \usepackage[%pdftex, % needed for pdflatex
26 \usepackage[%pdftex, % needed for pdflatex
27 breaklinks=true, % so long urls are correctly broken across lines
27 breaklinks=true, % so long urls are correctly broken across lines
28 colorlinks=true,
28 colorlinks=true,
29 urlcolor=blue,
29 urlcolor=blue,
30 linkcolor=darkred,
30 linkcolor=darkred,
31 citecolor=darkgreen,
31 citecolor=darkgreen,
32 ]{hyperref}
32 ]{hyperref}
33
33
34 \usepackage{html}
34 \usepackage{html}
35
35
36 % This helps prevent overly long lines that stretch beyond the margins
36 % This helps prevent overly long lines that stretch beyond the margins
37 \sloppy
37 \sloppy
38
38
39 % Define a \codelist command which either uses listings for latex, or
39 % Define a \codelist command which either uses listings for latex, or
40 % plain verbatim for html (since latex2html doesn't understand the
40 % plain verbatim for html (since latex2html doesn't understand the
41 % listings package).
41 % listings package).
42 \usepackage{verbatim}
42 \usepackage{verbatim}
43 \newcommand{\codelist}[1] {
43 \newcommand{\codelist}[1] {
44 \latex{\lstinputlisting{#1}}
44 \latex{\lstinputlisting{#1}}
45 \html{\verbatiminput{#1}}
45 \html{\verbatiminput{#1}}
46 }
46 }
47 \end_preamble
47 \end_preamble
48 \language english
48 \language english
49 \inputencoding latin1
49 \inputencoding latin1
50 \fontscheme palatino
50 \fontscheme palatino
51 \graphics default
51 \graphics default
52 \paperfontsize 10
52 \paperfontsize 10
53 \spacing single
53 \spacing single
54 \papersize Default
54 \papersize Default
55 \paperpackage a4
55 \paperpackage a4
56 \use_geometry 1
56 \use_geometry 1
57 \use_amsmath 0
57 \use_amsmath 0
58 \use_natbib 0
58 \use_natbib 0
59 \use_numerical_citations 0
59 \use_numerical_citations 0
60 \paperorientation portrait
60 \paperorientation portrait
61 \leftmargin 1.1in
61 \leftmargin 1.1in
62 \topmargin 1in
62 \topmargin 1in
63 \rightmargin 1.1in
63 \rightmargin 1.1in
64 \bottommargin 1in
64 \bottommargin 1in
65 \secnumdepth 3
65 \secnumdepth 3
66 \tocdepth 3
66 \tocdepth 3
67 \paragraph_separation skip
67 \paragraph_separation skip
68 \defskip medskip
68 \defskip medskip
69 \quotes_language english
69 \quotes_language english
70 \quotes_times 2
70 \quotes_times 2
71 \papercolumns 1
71 \papercolumns 1
72 \papersides 1
72 \papersides 1
73 \paperpagestyle fancy
73 \paperpagestyle fancy
74
74
75 \layout Title
75 \layout Title
76
76
77 IPython
77 IPython
78 \newline
78 \newline
79
79
80 \size larger
80 \size larger
81 An enhanced Interactive Python
81 An enhanced Interactive Python
82 \size large
82 \size large
83
83
84 \newline
84 \newline
85 User Manual, v.
85 User Manual, v.
86 __version__
86 __version__
87 \layout Author
87 \layout Author
88
88
89 Fernando PοΏ½rez
89 Fernando PοΏ½rez
90 \layout Standard
90 \layout Standard
91
91
92
92
93 \begin_inset ERT
93 \begin_inset ERT
94 status Collapsed
94 status Collapsed
95
95
96 \layout Standard
96 \layout Standard
97
97
98 \backslash
98 \backslash
99 latex{
99 latex{
100 \end_inset
100 \end_inset
101
101
102
102
103 \begin_inset LatexCommand \tableofcontents{}
103 \begin_inset LatexCommand \tableofcontents{}
104
104
105 \end_inset
105 \end_inset
106
106
107
107
108 \begin_inset ERT
108 \begin_inset ERT
109 status Collapsed
109 status Collapsed
110
110
111 \layout Standard
111 \layout Standard
112 }
112 }
113 \end_inset
113 \end_inset
114
114
115
115
116 \layout Standard
116 \layout Standard
117
117
118
118
119 \begin_inset ERT
119 \begin_inset ERT
120 status Open
120 status Open
121
121
122 \layout Standard
122 \layout Standard
123
123
124 \backslash
124 \backslash
125 html{
125 html{
126 \backslash
126 \backslash
127 bodytext{bgcolor=#ffffff}}
127 bodytext{bgcolor=#ffffff}}
128 \end_inset
128 \end_inset
129
129
130
130
131 \layout Section
131 \layout Section
132 \pagebreak_top
132 \pagebreak_top
133 Overview
133 Overview
134 \layout Standard
134 \layout Standard
135
135
136 One of Python's most useful features is its interactive interpreter.
136 One of Python's most useful features is its interactive interpreter.
137 This system allows very fast testing of ideas without the overhead of creating
137 This system allows very fast testing of ideas without the overhead of creating
138 test files as is typical in most programming languages.
138 test files as is typical in most programming languages.
139 However, the interpreter supplied with the standard Python distribution
139 However, the interpreter supplied with the standard Python distribution
140 is somewhat limited for extended interactive use.
140 is somewhat limited for extended interactive use.
141 \layout Standard
141 \layout Standard
142
142
143 IPython is a free software project (released under the BSD license) which
143 IPython is a free software project (released under the BSD license) which
144 tries to:
144 tries to:
145 \layout Enumerate
145 \layout Enumerate
146
146
147 Provide an interactive shell superior to Python's default.
147 Provide an interactive shell superior to Python's default.
148 IPython has many features for object introspection, system shell access,
148 IPython has many features for object introspection, system shell access,
149 and its own special command system for adding functionality when working
149 and its own special command system for adding functionality when working
150 interactively.
150 interactively.
151 It tries to be a very efficient environment both for Python code development
151 It tries to be a very efficient environment both for Python code development
152 and for exploration of problems using Python objects (in situations like
152 and for exploration of problems using Python objects (in situations like
153 data analysis).
153 data analysis).
154 \layout Enumerate
154 \layout Enumerate
155
155
156 Serve as an embeddable, ready to use interpreter for your own programs.
156 Serve as an embeddable, ready to use interpreter for your own programs.
157 IPython can be started with a single call from inside another program,
157 IPython can be started with a single call from inside another program,
158 providing access to the current namespace.
158 providing access to the current namespace.
159 This can be very useful both for debugging purposes and for situations
159 This can be very useful both for debugging purposes and for situations
160 where a blend of batch-processing and interactive exploration are needed.
160 where a blend of batch-processing and interactive exploration are needed.
161 \layout Enumerate
161 \layout Enumerate
162
162
163 Offer a flexible framework which can be used as the base environment for
163 Offer a flexible framework which can be used as the base environment for
164 other systems with Python as the underlying language.
164 other systems with Python as the underlying language.
165 Specifically scientific environments like Mathematica, IDL and Matlab inspired
165 Specifically scientific environments like Mathematica, IDL and Matlab inspired
166 its design, but similar ideas can be useful in many fields.
166 its design, but similar ideas can be useful in many fields.
167 \layout Subsection
167 \layout Subsection
168
168
169 Main features
169 Main features
170 \layout Itemize
170 \layout Itemize
171
171
172 Dynamic object introspection.
172 Dynamic object introspection.
173 One can access docstrings, function definition prototypes, source code,
173 One can access docstrings, function definition prototypes, source code,
174 source files and other details of any object accessible to the interpreter
174 source files and other details of any object accessible to the interpreter
175 with a single keystroke (`
175 with a single keystroke (`
176 \family typewriter
176 \family typewriter
177 ?
177 ?
178 \family default
178 \family default
179 ').
179 ').
180 \layout Itemize
180 \layout Itemize
181
181
182 Completion in the local namespace, by typing TAB at the prompt.
182 Completion in the local namespace, by typing TAB at the prompt.
183 This works for keywords, methods, variables and files in the current directory.
183 This works for keywords, methods, variables and files in the current directory.
184 This is supported via the readline library, and full access to configuring
184 This is supported via the readline library, and full access to configuring
185 readline's behavior is provided.
185 readline's behavior is provided.
186 \layout Itemize
186 \layout Itemize
187
187
188 Numbered input/output prompts with command history (persistent across sessions
188 Numbered input/output prompts with command history (persistent across sessions
189 and tied to each profile), full searching in this history and caching of
189 and tied to each profile), full searching in this history and caching of
190 all input and output.
190 all input and output.
191 \layout Itemize
191 \layout Itemize
192
192
193 User-extensible `magic' commands.
193 User-extensible `magic' commands.
194 A set of commands prefixed with
194 A set of commands prefixed with
195 \family typewriter
195 \family typewriter
196 %
196 %
197 \family default
197 \family default
198 is available for controlling IPython itself and provides directory control,
198 is available for controlling IPython itself and provides directory control,
199 namespace information and many aliases to common system shell commands.
199 namespace information and many aliases to common system shell commands.
200 \layout Itemize
200 \layout Itemize
201
201
202 Alias facility for defining your own system aliases.
202 Alias facility for defining your own system aliases.
203 \layout Itemize
203 \layout Itemize
204
204
205 Complete system shell access.
205 Complete system shell access.
206 Lines starting with ! are passed directly to the system shell, and using
206 Lines starting with ! are passed directly to the system shell, and using
207 !! captures shell output into python variables for further use.
207 !! captures shell output into python variables for further use.
208 \layout Itemize
208 \layout Itemize
209
209
210 All calls to the system (via aliases or via !) have their standard output/error
210 All calls to the system (via aliases or via !) have their standard output/error
211 automatically stored as strings, and also available as lists.
211 automatically stored as strings, and also available as lists.
212 \layout Itemize
212 \layout Itemize
213
213
214 Background execution of Python commands in a separate thread.
214 Background execution of Python commands in a separate thread.
215 IPython has an internal job manager called
215 IPython has an internal job manager called
216 \family typewriter
216 \family typewriter
217 jobs
217 jobs
218 \family default
218 \family default
219 , and a conveninence backgrounding magic function called
219 , and a conveninence backgrounding magic function called
220 \family typewriter
220 \family typewriter
221 %bg
221 %bg
222 \family default
222 \family default
223 .
223 .
224 \layout Itemize
224 \layout Itemize
225
225
226 The ability to expand python variables when calling the system shell.
226 The ability to expand python variables when calling the system shell.
227 In a shell command, any python variable prefixed with
227 In a shell command, any python variable prefixed with
228 \family typewriter
228 \family typewriter
229 $
229 $
230 \family default
230 \family default
231 is expanded.
231 is expanded.
232 A double
232 A double
233 \family typewriter
233 \family typewriter
234 $$
234 $$
235 \family default
235 \family default
236 allows passing a literal
236 allows passing a literal
237 \family typewriter
237 \family typewriter
238 $
238 $
239 \family default
239 \family default
240 to the shell (for access to shell and environment variables like
240 to the shell (for access to shell and environment variables like
241 \family typewriter
241 \family typewriter
242 $PATH
242 $PATH
243 \family default
243 \family default
244 ).
244 ).
245 \layout Itemize
245 \layout Itemize
246
246
247 Filesystem navigation, via a magic
247 Filesystem navigation, via a magic
248 \family typewriter
248 \family typewriter
249 %cd
249 %cd
250 \family default
250 \family default
251 command, along with a persistent bookmark system (using
251 command, along with a persistent bookmark system (using
252 \family typewriter
252 \family typewriter
253 %bookmark
253 %bookmark
254 \family default
254 \family default
255 ) for fast access to frequently visited directories.
255 ) for fast access to frequently visited directories.
256 \layout Itemize
256 \layout Itemize
257
257
258 Automatic indentation (optional) of code as you type (through the readline
258 Automatic indentation (optional) of code as you type (through the readline
259 library).
259 library).
260 \layout Itemize
260 \layout Itemize
261
261
262 Macro system for quickly re-executing multiple lines of previous input with
262 Macro system for quickly re-executing multiple lines of previous input with
263 a single name.
263 a single name.
264 \layout Itemize
264 \layout Itemize
265
265
266 Session logging (you can then later use these logs as code in your programs).
266 Session logging (you can then later use these logs as code in your programs).
267 \layout Itemize
267 \layout Itemize
268
268
269 Session restoring: logs can be replayed to restore a previous session to
269 Session restoring: logs can be replayed to restore a previous session to
270 the state where you left it.
270 the state where you left it.
271 \layout Itemize
271 \layout Itemize
272
272
273 Verbose and colored exception traceback printouts.
273 Verbose and colored exception traceback printouts.
274 Easier to parse visually, and in verbose mode they produce a lot of useful
274 Easier to parse visually, and in verbose mode they produce a lot of useful
275 debugging information (basically a terminal version of the cgitb module).
275 debugging information (basically a terminal version of the cgitb module).
276 \layout Itemize
276 \layout Itemize
277
277
278 Auto-parentheses: callable objects can be executed without parentheses:
278 Auto-parentheses: callable objects can be executed without parentheses:
279
279
280 \family typewriter
280 \family typewriter
281 `sin 3'
281 `sin 3'
282 \family default
282 \family default
283 is automatically converted to
283 is automatically converted to
284 \family typewriter
284 \family typewriter
285 `sin(3)
285 `sin(3)
286 \family default
286 \family default
287 '.
287 '.
288 \layout Itemize
288 \layout Itemize
289
289
290 Auto-quoting: using `
290 Auto-quoting: using `
291 \family typewriter
291 \family typewriter
292 ,
292 ,
293 \family default
293 \family default
294 ' or `
294 ' or `
295 \family typewriter
295 \family typewriter
296 ;
296 ;
297 \family default
297 \family default
298 ' as the first character forces auto-quoting of the rest of the line:
298 ' as the first character forces auto-quoting of the rest of the line:
299 \family typewriter
299 \family typewriter
300 `,my_function a\SpecialChar ~
300 `,my_function a\SpecialChar ~
301 b'
301 b'
302 \family default
302 \family default
303 becomes automatically
303 becomes automatically
304 \family typewriter
304 \family typewriter
305 `my_function("a","b")'
305 `my_function("a","b")'
306 \family default
306 \family default
307 , while
307 , while
308 \family typewriter
308 \family typewriter
309 `;my_function a\SpecialChar ~
309 `;my_function a\SpecialChar ~
310 b'
310 b'
311 \family default
311 \family default
312 becomes
312 becomes
313 \family typewriter
313 \family typewriter
314 `my_function("a b")'
314 `my_function("a b")'
315 \family default
315 \family default
316 .
316 .
317 \layout Itemize
317 \layout Itemize
318
318
319 Extensible input syntax.
319 Extensible input syntax.
320 You can define filters that pre-process user input to simplify input in
320 You can define filters that pre-process user input to simplify input in
321 special situations.
321 special situations.
322 This allows for example pasting multi-line code fragments which start with
322 This allows for example pasting multi-line code fragments which start with
323
323
324 \family typewriter
324 \family typewriter
325 `>>>'
325 `>>>'
326 \family default
326 \family default
327 or
327 or
328 \family typewriter
328 \family typewriter
329 `...'
329 `...'
330 \family default
330 \family default
331 such as those from other python sessions or the standard Python documentation.
331 such as those from other python sessions or the standard Python documentation.
332 \layout Itemize
332 \layout Itemize
333
333
334 Flexible configuration system.
334 Flexible configuration system.
335 It uses a configuration file which allows permanent setting of all command-line
335 It uses a configuration file which allows permanent setting of all command-line
336 options, module loading, code and file execution.
336 options, module loading, code and file execution.
337 The system allows recursive file inclusion, so you can have a base file
337 The system allows recursive file inclusion, so you can have a base file
338 with defaults and layers which load other customizations for particular
338 with defaults and layers which load other customizations for particular
339 projects.
339 projects.
340 \layout Itemize
340 \layout Itemize
341
341
342 Embeddable.
342 Embeddable.
343 You can call IPython as a python shell inside your own python programs.
343 You can call IPython as a python shell inside your own python programs.
344 This can be used both for debugging code or for providing interactive abilities
344 This can be used both for debugging code or for providing interactive abilities
345 to your programs with knowledge about the local namespaces (very useful
345 to your programs with knowledge about the local namespaces (very useful
346 in debugging and data analysis situations).
346 in debugging and data analysis situations).
347 \layout Itemize
347 \layout Itemize
348
348
349 Easy debugger access.
349 Easy debugger access.
350 You can set IPython to call up the Python debugger (pdb) every time there
350 You can set IPython to call up the Python debugger (pdb) every time there
351 is an uncaught exception.
351 is an uncaught exception.
352 This drops you inside the code which triggered the exception with all the
352 This drops you inside the code which triggered the exception with all the
353 data live and it is possible to navigate the stack to rapidly isolate the
353 data live and it is possible to navigate the stack to rapidly isolate the
354 source of a bug.
354 source of a bug.
355 The
355 The
356 \family typewriter
356 \family typewriter
357 %run
357 %run
358 \family default
358 \family default
359 magic command --with the
359 magic command --with the
360 \family typewriter
360 \family typewriter
361 -d
361 -d
362 \family default
362 \family default
363 option-- can run any script under
363 option-- can run any script under
364 \family typewriter
364 \family typewriter
365 pdb
365 pdb
366 \family default
366 \family default
367 's control, automatically setting initial breakpoints for you.
367 's control, automatically setting initial breakpoints for you.
368 \layout Itemize
368 \layout Itemize
369
369
370 Profiler support.
370 Profiler support.
371 You can run single statements (similar to
371 You can run single statements (similar to
372 \family typewriter
372 \family typewriter
373 profile.run()
373 profile.run()
374 \family default
374 \family default
375 ) or complete programs under the profiler's control.
375 ) or complete programs under the profiler's control.
376 While this is possible with the standard
376 While this is possible with the standard
377 \family typewriter
377 \family typewriter
378 profile
378 profile
379 \family default
379 \family default
380 module, IPython wraps this functionality with magic commands (see
380 module, IPython wraps this functionality with magic commands (see
381 \family typewriter
381 \family typewriter
382 `%prun'
382 `%prun'
383 \family default
383 \family default
384 and
384 and
385 \family typewriter
385 \family typewriter
386 `%run -p
386 `%run -p
387 \family default
387 \family default
388 ') convenient for rapid interactive work.
388 ') convenient for rapid interactive work.
389 \layout Subsection
389 \layout Subsection
390
390
391 Portability and Python requirements
391 Portability and Python requirements
392 \layout Standard
392 \layout Standard
393
393
394
394
395 \series bold
395 \series bold
396 Python requirements:
396 Python requirements:
397 \series default
397 \series default
398 IPython works with Python version 2.2 or newer.
398 IPython works with Python version 2.2 or newer.
399 It has been tested with Python 2.4 and no problems have been reported.
399 It has been tested with Python 2.4 and no problems have been reported.
400 Support for Python 2.1 hasn't been recently tested, since I don't have access
400 Support for Python 2.1 hasn't been recently tested, since I don't have access
401 to it on any of my systems.
401 to it on any of my systems.
402 But I suspect there may be some problems with Python 2.1, because some of
402 But I suspect there may be some problems with Python 2.1, because some of
403 the newer code may use 2.2 features.
403 the newer code may use 2.2 features.
404 \layout Standard
404 \layout Standard
405
405
406 IPython is developed under
406 IPython is developed under
407 \series bold
407 \series bold
408 Linux
408 Linux
409 \series default
409 \series default
410 , but it should work in any reasonable Unix-type system (tested OK under
410 , but it should work in any reasonable Unix-type system (tested OK under
411 Solaris and the *BSD family, for which a port exists thanks to Dryice Liu).
411 Solaris and the *BSD family, for which a port exists thanks to Dryice Liu).
412 \layout Standard
412 \layout Standard
413
413
414
414
415 \series bold
415 \series bold
416 Mac OS X
416 Mac OS X
417 \series default
417 \series default
418 : it works, apparently without any problems (thanks to Jim Boyle at Lawrence
418 : it works, apparently without any problems (thanks to Jim Boyle at Lawrence
419 Livermore for the information).
419 Livermore for the information).
420 Thanks to Andrea Riciputi, Fink support is available.
420 Thanks to Andrea Riciputi, Fink support is available.
421 \layout Standard
421 \layout Standard
422
422
423
423
424 \series bold
424 \series bold
425 CygWin
425 CygWin
426 \series default
426 \series default
427 : it works mostly OK, though some users have reported problems with prompt
427 : it works mostly OK, though some users have reported problems with prompt
428 coloring.
428 coloring.
429 No satisfactory solution to this has been found so far, you may want to
429 No satisfactory solution to this has been found so far, you may want to
430 disable colors permanently in the
430 disable colors permanently in the
431 \family typewriter
431 \family typewriter
432 ipythonrc
432 ipythonrc
433 \family default
433 \family default
434 configuration file if you experience problems.
434 configuration file if you experience problems.
435 If you have proper color support under cygwin, please post to the IPython
435 If you have proper color support under cygwin, please post to the IPython
436 mailing list so this issue can be resolved for all users.
436 mailing list so this issue can be resolved for all users.
437 \layout Standard
437 \layout Standard
438
438
439
439
440 \series bold
440 \series bold
441 Windows
441 Windows
442 \series default
442 \series default
443 : it works well under Windows XP/2k, and I suspect NT should behave similarly.
443 : it works well under Windows XP/2k, and I suspect NT should behave similarly.
444 Section\SpecialChar ~
444 Section\SpecialChar ~
445
445
446 \begin_inset LatexCommand \ref{sub:Under-Windows}
446 \begin_inset LatexCommand \ref{sub:Under-Windows}
447
447
448 \end_inset
448 \end_inset
449
449
450 describes installation details for Windows, including some additional tools
450 describes installation details for Windows, including some additional tools
451 needed on this platform.
451 needed on this platform.
452 \layout Standard
452 \layout Standard
453
453
454 Windows 9x support is present, and has been reported to work fine (at least
454 Windows 9x support is present, and has been reported to work fine (at least
455 on WinME).
455 on WinME).
456 \layout Standard
456 \layout Standard
457
457
458 Please note, however, that I have very little access to and experience with
458 Please note, however, that I have very little access to and experience with
459 Windows development.
459 Windows development.
460 For this reason, Windows-specific bugs tend to linger far longer than I
460 For this reason, Windows-specific bugs tend to linger far longer than I
461 would like, and often I just can't find a satisfactory solution.
461 would like, and often I just can't find a satisfactory solution.
462 If any Windows user wants to join in with development help, all hands are
462 If any Windows user wants to join in with development help, all hands are
463 always welcome.
463 always welcome.
464 \layout Subsection
464 \layout Subsection
465
465
466 Location
466 Location
467 \layout Standard
467 \layout Standard
468
468
469 IPython is generously hosted at
469 IPython is generously hosted at
470 \begin_inset LatexCommand \htmlurl{http://ipython.scipy.org}
470 \begin_inset LatexCommand \htmlurl{http://ipython.scipy.org}
471
471
472 \end_inset
472 \end_inset
473
473
474 by the SciPy project.
474 by the SciPy project.
475 This site offers downloads, subversion access, mailing lists and a bug
475 This site offers downloads, subversion access, mailing lists and a bug
476 tracking system.
476 tracking system.
477 I am very grateful to Enthought (
477 I am very grateful to Enthought (
478 \begin_inset LatexCommand \htmlurl{http://www.enthought.com}
478 \begin_inset LatexCommand \htmlurl{http://www.enthought.com}
479
479
480 \end_inset
480 \end_inset
481
481
482 ) and all of the SciPy team for their contribution.
482 ) and all of the SciPy team for their contribution.
483 \layout Section
483 \layout Section
484
484
485
485
486 \begin_inset LatexCommand \label{sec:install}
486 \begin_inset LatexCommand \label{sec:install}
487
487
488 \end_inset
488 \end_inset
489
489
490 Installation
490 Installation
491 \layout Subsection
491 \layout Subsection
492
492
493 Instant instructions
493 Instant instructions
494 \layout Standard
494 \layout Standard
495
495
496 If you are of the impatient kind, under Linux/Unix simply untar/unzip the
496 If you are of the impatient kind, under Linux/Unix simply untar/unzip the
497 download, then install with
497 download, then install with
498 \family typewriter
498 \family typewriter
499 `python setup.py install'
499 `python setup.py install'
500 \family default
500 \family default
501 .
501 .
502 Under Windows, double-click on the provided
502 Under Windows, double-click on the provided
503 \family typewriter
503 \family typewriter
504 .exe
504 .exe
505 \family default
505 \family default
506 binary installer.
506 binary installer.
507 \layout Standard
507 \layout Standard
508
508
509 Then, take a look at Sections
509 Then, take a look at Sections
510 \begin_inset LatexCommand \ref{sec:good_config}
510 \begin_inset LatexCommand \ref{sec:good_config}
511
511
512 \end_inset
512 \end_inset
513
513
514 for configuring things optimally and
514 for configuring things optimally and
515 \begin_inset LatexCommand \ref{sec:quick_tips}
515 \begin_inset LatexCommand \ref{sec:quick_tips}
516
516
517 \end_inset
517 \end_inset
518
518
519 for quick tips on efficient use of IPython.
519 for quick tips on efficient use of IPython.
520 You can later refer to the rest of the manual for all the gory details.
520 You can later refer to the rest of the manual for all the gory details.
521 \layout Standard
521 \layout Standard
522
522
523 See the notes in sec.
523 See the notes in sec.
524
524
525 \begin_inset LatexCommand \ref{sec:upgrade}
525 \begin_inset LatexCommand \ref{sec:upgrade}
526
526
527 \end_inset
527 \end_inset
528
528
529 for upgrading IPython versions.
529 for upgrading IPython versions.
530 \layout Subsection
530 \layout Subsection
531
531
532 Detailed Unix instructions (Linux, Mac OS X, etc.)
532 Detailed Unix instructions (Linux, Mac OS X, etc.)
533 \layout Standard
533 \layout Standard
534
534
535 For RPM based systems, simply install the supplied package in the usual
535 For RPM based systems, simply install the supplied package in the usual
536 manner.
536 manner.
537 If you download the tar archive, the process is:
537 If you download the tar archive, the process is:
538 \layout Enumerate
538 \layout Enumerate
539
539
540 Unzip/untar the
540 Unzip/untar the
541 \family typewriter
541 \family typewriter
542 ipython-XXX.tar.gz
542 ipython-XXX.tar.gz
543 \family default
543 \family default
544 file wherever you want (
544 file wherever you want (
545 \family typewriter
545 \family typewriter
546 XXX
546 XXX
547 \family default
547 \family default
548 is the version number).
548 is the version number).
549 It will make a directory called
549 It will make a directory called
550 \family typewriter
550 \family typewriter
551 ipython-XXX.
551 ipython-XXX.
552
552
553 \family default
553 \family default
554 Change into that directory where you will find the files
554 Change into that directory where you will find the files
555 \family typewriter
555 \family typewriter
556 README
556 README
557 \family default
557 \family default
558 and
558 and
559 \family typewriter
559 \family typewriter
560 setup.py
560 setup.py
561 \family default
561 \family default
562 .
562 .
563
563
564 \family typewriter
564 \family typewriter
565 O
565 O
566 \family default
566 \family default
567 nce you've completed the installation, you can safely remove this directory.
567 nce you've completed the installation, you can safely remove this directory.
568
568
569 \layout Enumerate
569 \layout Enumerate
570
570
571 If you are installing over a previous installation of version 0.2.0 or earlier,
571 If you are installing over a previous installation of version 0.2.0 or earlier,
572 first remove your
572 first remove your
573 \family typewriter
573 \family typewriter
574 $HOME/.ipython
574 $HOME/.ipython
575 \family default
575 \family default
576 directory, since the configuration file format has changed somewhat (the
576 directory, since the configuration file format has changed somewhat (the
577 '=' were removed from all option specifications).
577 '=' were removed from all option specifications).
578 Or you can call ipython with the
578 Or you can call ipython with the
579 \family typewriter
579 \family typewriter
580 -upgrade
580 -upgrade
581 \family default
581 \family default
582 option and it will do this automatically for you.
582 option and it will do this automatically for you.
583 \layout Enumerate
583 \layout Enumerate
584
584
585 IPython uses distutils, so you can install it by simply typing at the system
585 IPython uses distutils, so you can install it by simply typing at the system
586 prompt (don't type the
586 prompt (don't type the
587 \family typewriter
587 \family typewriter
588 $
588 $
589 \family default
589 \family default
590 )
590 )
591 \newline
591 \newline
592
592
593 \family typewriter
593 \family typewriter
594 $ python setup.py install
594 $ python setup.py install
595 \family default
595 \family default
596
596
597 \newline
597 \newline
598 Note that this assumes you have root access to your machine.
598 Note that this assumes you have root access to your machine.
599 If you don't have root access or don't want IPython to go in the default
599 If you don't have root access or don't want IPython to go in the default
600 python directories, you'll need to use the
600 python directories, you'll need to use the
601 \begin_inset ERT
601 \begin_inset ERT
602 status Collapsed
602 status Collapsed
603
603
604 \layout Standard
604 \layout Standard
605
605
606 \backslash
606 \backslash
607 verb|--home|
607 verb|--home|
608 \end_inset
608 \end_inset
609
609
610 option (or
610 option (or
611 \begin_inset ERT
611 \begin_inset ERT
612 status Collapsed
612 status Collapsed
613
613
614 \layout Standard
614 \layout Standard
615
615
616 \backslash
616 \backslash
617 verb|--prefix|
617 verb|--prefix|
618 \end_inset
618 \end_inset
619
619
620 ).
620 ).
621 For example:
621 For example:
622 \newline
622 \newline
623
623
624 \begin_inset ERT
624 \begin_inset ERT
625 status Collapsed
625 status Collapsed
626
626
627 \layout Standard
627 \layout Standard
628
628
629 \backslash
629 \backslash
630 verb|$ python setup.py install --home $HOME/local|
630 verb|$ python setup.py install --home $HOME/local|
631 \end_inset
631 \end_inset
632
632
633
633
634 \newline
634 \newline
635 will install IPython into
635 will install IPython into
636 \family typewriter
636 \family typewriter
637 $HOME/local
637 $HOME/local
638 \family default
638 \family default
639 and its subdirectories (creating them if necessary).
639 and its subdirectories (creating them if necessary).
640 \newline
640 \newline
641 You can type
641 You can type
642 \newline
642 \newline
643
643
644 \begin_inset ERT
644 \begin_inset ERT
645 status Collapsed
645 status Collapsed
646
646
647 \layout Standard
647 \layout Standard
648
648
649 \backslash
649 \backslash
650 verb|$ python setup.py --help|
650 verb|$ python setup.py --help|
651 \end_inset
651 \end_inset
652
652
653
653
654 \newline
654 \newline
655 for more details.
655 for more details.
656 \newline
656 \newline
657 Note that if you change the default location for
657 Note that if you change the default location for
658 \begin_inset ERT
658 \begin_inset ERT
659 status Collapsed
659 status Collapsed
660
660
661 \layout Standard
661 \layout Standard
662
662
663 \backslash
663 \backslash
664 verb|--home|
664 verb|--home|
665 \end_inset
665 \end_inset
666
666
667 at installation, IPython may end up installed at a location which is not
667 at installation, IPython may end up installed at a location which is not
668 part of your
668 part of your
669 \family typewriter
669 \family typewriter
670 $PYTHONPATH
670 $PYTHONPATH
671 \family default
671 \family default
672 environment variable.
672 environment variable.
673 In this case, you'll need to configure this variable to include the actual
673 In this case, you'll need to configure this variable to include the actual
674 directory where the
674 directory where the
675 \family typewriter
675 \family typewriter
676 IPython/
676 IPython/
677 \family default
677 \family default
678 directory ended (typically the value you give to
678 directory ended (typically the value you give to
679 \begin_inset ERT
679 \begin_inset ERT
680 status Collapsed
680 status Collapsed
681
681
682 \layout Standard
682 \layout Standard
683
683
684 \backslash
684 \backslash
685 verb|--home|
685 verb|--home|
686 \end_inset
686 \end_inset
687
687
688 plus
688 plus
689 \family typewriter
689 \family typewriter
690 /lib/python
690 /lib/python
691 \family default
691 \family default
692 ).
692 ).
693 \layout Subsubsection
693 \layout Subsubsection
694
694
695 Mac OSX information
695 Mac OSX information
696 \layout Standard
696 \layout Standard
697
697
698 Under OSX, there is a choice you need to make.
698 Under OSX, there is a choice you need to make.
699 Apple ships its own build of Python, which lives in the core OSX filesystem
699 Apple ships its own build of Python, which lives in the core OSX filesystem
700 hierarchy.
700 hierarchy.
701 You can also manually install a separate Python, either purely by hand
701 You can also manually install a separate Python, either purely by hand
702 (typically in
702 (typically in
703 \family typewriter
703 \family typewriter
704 /usr/local
704 /usr/local
705 \family default
705 \family default
706 ) or by using Fink, which puts everything under
706 ) or by using Fink, which puts everything under
707 \family typewriter
707 \family typewriter
708 /sw
708 /sw
709 \family default
709 \family default
710 .
710 .
711 Which route to follow is a matter of personal preference, as I've seen
711 Which route to follow is a matter of personal preference, as I've seen
712 users who favor each of the approaches.
712 users who favor each of the approaches.
713 Here I will simply list the known installation issues under OSX, along
713 Here I will simply list the known installation issues under OSX, along
714 with their solutions.
714 with their solutions.
715 \layout Standard
715 \layout Standard
716
716
717 This page:
717 This page:
718 \begin_inset LatexCommand \htmlurl{http://geosci.uchicago.edu/~tobis/pylab.html}
718 \begin_inset LatexCommand \htmlurl{http://geosci.uchicago.edu/~tobis/pylab.html}
719
719
720 \end_inset
720 \end_inset
721
721
722 contains information on this topic, with additional details on how to make
722 contains information on this topic, with additional details on how to make
723 IPython and matplotlib play nicely under OSX.
723 IPython and matplotlib play nicely under OSX.
724 \layout Subsubsection*
724 \layout Subsubsection*
725
725
726 GUI problems
726 GUI problems
727 \layout Standard
727 \layout Standard
728
728
729 The following instructions apply to an install of IPython under OSX from
729 The following instructions apply to an install of IPython under OSX from
730 unpacking the
730 unpacking the
731 \family typewriter
731 \family typewriter
732 .tar.gz
732 .tar.gz
733 \family default
733 \family default
734 distribution and installing it for the default Python interpreter shipped
734 distribution and installing it for the default Python interpreter shipped
735 by Apple.
735 by Apple.
736 If you are using a fink install, fink will take care of these details for
736 If you are using a fink install, fink will take care of these details for
737 you, by installing IPython against fink's Python.
737 you, by installing IPython against fink's Python.
738 \layout Standard
738 \layout Standard
739
739
740 IPython offers various forms of support for interacting with graphical applicati
740 IPython offers various forms of support for interacting with graphical applicati
741 ons from the command line, from simple Tk apps (which are in principle always
741 ons from the command line, from simple Tk apps (which are in principle always
742 supported by Python) to interactive control of WX, Qt and GTK apps.
742 supported by Python) to interactive control of WX, Qt and GTK apps.
743 Under OSX, however, this requires that ipython is installed by calling
743 Under OSX, however, this requires that ipython is installed by calling
744 the special
744 the special
745 \family typewriter
745 \family typewriter
746 pythonw
746 pythonw
747 \family default
747 \family default
748 script at installation time, which takes care of coordinating things with
748 script at installation time, which takes care of coordinating things with
749 Apple's graphical environment.
749 Apple's graphical environment.
750 \layout Standard
750 \layout Standard
751
751
752 So when installing under OSX, it is best to use the following command:
752 So when installing under OSX, it is best to use the following command:
753 \family typewriter
753 \family typewriter
754
754
755 \newline
755 \newline
756
756
757 \family default
757 \family default
758
758
759 \begin_inset ERT
759 \begin_inset ERT
760 status Collapsed
760 status Collapsed
761
761
762 \layout Standard
762 \layout Standard
763
763
764 \backslash
764 \backslash
765 verb| $ sudo pythonw setup.py install --install-scripts=/usr/local/bin|
765 verb| $ sudo pythonw setup.py install --install-scripts=/usr/local/bin|
766 \end_inset
766 \end_inset
767
767
768
768
769 \newline
769 \newline
770 or
770 or
771 \newline
771 \newline
772
772
773 \begin_inset ERT
773 \begin_inset ERT
774 status Open
774 status Open
775
775
776 \layout Standard
776 \layout Standard
777
777
778 \backslash
778 \backslash
779 verb| $ sudo pythonw setup.py install --install-scripts=/usr/bin|
779 verb| $ sudo pythonw setup.py install --install-scripts=/usr/bin|
780 \end_inset
780 \end_inset
781
781
782
782
783 \newline
783 \newline
784 depending on where you like to keep hand-installed executables.
784 depending on where you like to keep hand-installed executables.
785 \layout Standard
785 \layout Standard
786
786
787 The resulting script will have an appropriate shebang line (the first line
787 The resulting script will have an appropriate shebang line (the first line
788 in the script whic begins with
788 in the script whic begins with
789 \family typewriter
789 \family typewriter
790 #!...
790 #!...
791 \family default
791 \family default
792 ) such that the ipython interpreter can interact with the OS X GUI.
792 ) such that the ipython interpreter can interact with the OS X GUI.
793 If the installed version does not work and has a shebang line that points
793 If the installed version does not work and has a shebang line that points
794 to, for example, just
794 to, for example, just
795 \family typewriter
795 \family typewriter
796 /usr/bin/python
796 /usr/bin/python
797 \family default
797 \family default
798 , then you might have a stale, cached version in your
798 , then you might have a stale, cached version in your
799 \family typewriter
799 \family typewriter
800 build/scripts-<python-version>
800 build/scripts-<python-version>
801 \family default
801 \family default
802 directory.
802 directory.
803 Delete that directory and rerun the
803 Delete that directory and rerun the
804 \family typewriter
804 \family typewriter
805 setup.py
805 setup.py
806 \family default
806 \family default
807 .
807 .
808
808
809 \layout Standard
809 \layout Standard
810
810
811 It is also a good idea to use the special flag
811 It is also a good idea to use the special flag
812 \begin_inset ERT
812 \begin_inset ERT
813 status Collapsed
813 status Collapsed
814
814
815 \layout Standard
815 \layout Standard
816
816
817 \backslash
817 \backslash
818 verb|--install-scripts|
818 verb|--install-scripts|
819 \end_inset
819 \end_inset
820
820
821 as indicated above, to ensure that the ipython scripts end up in a location
821 as indicated above, to ensure that the ipython scripts end up in a location
822 which is part of your
822 which is part of your
823 \family typewriter
823 \family typewriter
824 $PATH
824 $PATH
825 \family default
825 \family default
826 .
826 .
827 Otherwise Apple's Python will put the scripts in an internal directory
827 Otherwise Apple's Python will put the scripts in an internal directory
828 not available by default at the command line (if you use
828 not available by default at the command line (if you use
829 \family typewriter
829 \family typewriter
830 /usr/local/bin
830 /usr/local/bin
831 \family default
831 \family default
832 , you need to make sure this is in your
832 , you need to make sure this is in your
833 \family typewriter
833 \family typewriter
834 $PATH
834 $PATH
835 \family default
835 \family default
836 , which may not be true by default).
836 , which may not be true by default).
837 \layout Subsubsection*
837 \layout Subsubsection*
838
838
839 Readline problems
839 Readline problems
840 \layout Standard
840 \layout Standard
841
841
842 By default, the Python version shipped by Apple does
842 By default, the Python version shipped by Apple does
843 \emph on
843 \emph on
844 not
844 not
845 \emph default
845 \emph default
846 include the readline library, so central to IPython's behavior.
846 include the readline library, so central to IPython's behavior.
847 If you install IPython against Apple's Python, you will not have arrow
847 If you install IPython against Apple's Python, you will not have arrow
848 keys, tab completion, etc.
848 keys, tab completion, etc.
849 For Mac OSX 10.3 (Panther), you can find a prebuilt readline library here:
849 For Mac OSX 10.3 (Panther), you can find a prebuilt readline library here:
850 \newline
850 \newline
851
851
852 \begin_inset LatexCommand \htmlurl{http://pythonmac.org/packages/readline-5.0-py2.3-macosx10.3.zip}
852 \begin_inset LatexCommand \htmlurl{http://pythonmac.org/packages/readline-5.0-py2.3-macosx10.3.zip}
853
853
854 \end_inset
854 \end_inset
855
855
856
856
857 \layout Standard
857 \layout Standard
858
858
859 If you are using OSX 10.4 (Tiger), after installing this package you need
859 If you are using OSX 10.4 (Tiger), after installing this package you need
860 to either:
860 to either:
861 \layout Enumerate
861 \layout Enumerate
862
862
863 move
863 move
864 \family typewriter
864 \family typewriter
865 readline.so
865 readline.so
866 \family default
866 \family default
867 from
867 from
868 \family typewriter
868 \family typewriter
869 /Library/Python/2.3
869 /Library/Python/2.3
870 \family default
870 \family default
871 to
871 to
872 \family typewriter
872 \family typewriter
873 /Library/Python/2.3/site-packages
873 /Library/Python/2.3/site-packages
874 \family default
874 \family default
875 , or
875 , or
876 \layout Enumerate
876 \layout Enumerate
877
877
878 install
878 install
879 \begin_inset LatexCommand \htmlurl{http://pythonmac.org/packages/TigerPython23Compat.pkg.zip}
879 \begin_inset LatexCommand \htmlurl{http://pythonmac.org/packages/TigerPython23Compat.pkg.zip}
880
880
881 \end_inset
881 \end_inset
882
882
883
883
884 \layout Standard
884 \layout Standard
885
885
886 Users installing against Fink's Python or a properly hand-built one should
886 Users installing against Fink's Python or a properly hand-built one should
887 not have this problem.
887 not have this problem.
888 \layout Subsubsection*
888 \layout Subsubsection*
889
889
890 DarwinPorts
890 DarwinPorts
891 \layout Standard
891 \layout Standard
892
892
893 I report here a message from an OSX user, who suggests an alternative means
893 I report here a message from an OSX user, who suggests an alternative means
894 of using IPython under this operating system with good results.
894 of using IPython under this operating system with good results.
895 Please let me know of any updates that may be useful for this section.
895 Please let me know of any updates that may be useful for this section.
896 His message is reproduced verbatim below:
896 His message is reproduced verbatim below:
897 \layout Quote
897 \layout Quote
898
898
899 From: Markus Banfi
899 From: Markus Banfi
900 \family typewriter
900 \family typewriter
901 <markus.banfi-AT-mospheira.net>
901 <markus.banfi-AT-mospheira.net>
902 \layout Quote
902 \layout Quote
903
903
904 As a MacOS X (10.4.2) user I prefer to install software using DawinPorts instead
904 As a MacOS X (10.4.2) user I prefer to install software using DawinPorts instead
905 of Fink.
905 of Fink.
906 I had no problems installing ipython with DarwinPorts.
906 I had no problems installing ipython with DarwinPorts.
907 It's just:
907 It's just:
908 \layout Quote
908 \layout Quote
909
909
910
910
911 \family typewriter
911 \family typewriter
912 sudo port install py-ipython
912 sudo port install py-ipython
913 \layout Quote
913 \layout Quote
914
914
915 It automatically resolved all dependencies (python24, readline, py-readline).
915 It automatically resolved all dependencies (python24, readline, py-readline).
916 So far I did not encounter any problems with the DarwinPorts port of ipython.
916 So far I did not encounter any problems with the DarwinPorts port of ipython.
917
917
918 \layout Subsection
918 \layout Subsection
919
919
920
920
921 \begin_inset LatexCommand \label{sub:Under-Windows}
921 \begin_inset LatexCommand \label{sub:Under-Windows}
922
922
923 \end_inset
923 \end_inset
924
924
925 Windows instructions
925 Windows instructions
926 \layout Standard
926 \layout Standard
927
927
928 While you can use IPython under Windows with only a stock Python installation,
928 While you can use IPython under Windows with only a stock Python installation,
929 there is one extension,
929 there is one extension,
930 \family typewriter
930 \family typewriter
931 readline
931 readline
932 \family default
932 \family default
933 , which will make the whole experience a lot more pleasant.
933 , which will make the whole experience a lot more pleasant.
934 It is almost a requirement, since IPython will complain in its absence
934 It is almost a requirement, since IPython will complain in its absence
935 (though it will function).
935 (though it will function).
936
936
937 \layout Standard
937 \layout Standard
938
938
939 The
939 The
940 \family typewriter
940 \family typewriter
941 readline
941 readline
942 \family default
942 \family default
943 extension needs two other libraries to work, so in all you need:
943 extension needs two other libraries to work, so in all you need:
944 \layout Enumerate
944 \layout Enumerate
945
945
946
946
947 \family typewriter
947 \family typewriter
948 PyWin32
948 PyWin32
949 \family default
949 \family default
950 from
950 from
951 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/mhammond}
951 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/mhammond}
952
952
953 \end_inset
953 \end_inset
954
954
955 .
955 .
956 \layout Enumerate
956 \layout Enumerate
957
957
958
958
959 \family typewriter
959 \family typewriter
960 CTypes
960 CTypes
961 \family default
961 \family default
962 from
962 from
963 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/theller/ctypes}
963 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/theller/ctypes}
964
964
965 \end_inset
965 \end_inset
966
966
967 (you
967 (you
968 \emph on
968 \emph on
969 must
969 must
970 \emph default
970 \emph default
971 use version 0.9.1 or newer).
971 use version 0.9.1 or newer).
972 \layout Enumerate
972 \layout Enumerate
973
973
974
974
975 \family typewriter
975 \family typewriter
976 Readline
976 Readline
977 \family default
977 \family default
978 for Windows from
978 for Windows from
979 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/projects/uncpythontools}
979 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/projects/uncpythontools}
980
980
981 \end_inset
981 \end_inset
982
982
983 .
983 .
984 \layout Standard
984 \layout Standard
985
985
986
986
987 \series bold
987 \series bold
988 Warning about a broken readline-like library:
988 Warning about a broken readline-like library:
989 \series default
989 \series default
990 several users have reported problems stemming from using the pseudo-readline
990 several users have reported problems stemming from using the pseudo-readline
991 library at
991 library at
992 \begin_inset LatexCommand \htmlurl{http://newcenturycomputers.net/projects/readline.html}
992 \begin_inset LatexCommand \htmlurl{http://newcenturycomputers.net/projects/readline.html}
993
993
994 \end_inset
994 \end_inset
995
995
996 .
996 .
997 This is a broken library which, while called readline, only implements
997 This is a broken library which, while called readline, only implements
998 an incomplete subset of the readline API.
998 an incomplete subset of the readline API.
999 Since it is still called readline, it fools IPython's detection mechanisms
999 Since it is still called readline, it fools IPython's detection mechanisms
1000 and causes unpredictable crashes later.
1000 and causes unpredictable crashes later.
1001 If you wish to use IPython under Windows, you must NOT use this library,
1001 If you wish to use IPython under Windows, you must NOT use this library,
1002 which for all purposes is (at least as of version 1.6) terminally broken.
1002 which for all purposes is (at least as of version 1.6) terminally broken.
1003 \layout Subsubsection
1003 \layout Subsubsection
1004
1004
1005 Gary Bishop's readline and color support for Windows
1005 Gary Bishop's readline and color support for Windows
1006 \layout Standard
1006 \layout Standard
1007
1007
1008 Some of IPython's very useful features are:
1008 Some of IPython's very useful features are:
1009 \layout Itemize
1009 \layout Itemize
1010
1010
1011 Integrated readline support (Tab-based file, object and attribute completion,
1011 Integrated readline support (Tab-based file, object and attribute completion,
1012 input history across sessions, editable command line, etc.)
1012 input history across sessions, editable command line, etc.)
1013 \layout Itemize
1013 \layout Itemize
1014
1014
1015 Coloring of prompts, code and tracebacks.
1015 Coloring of prompts, code and tracebacks.
1016 \layout Standard
1016 \layout Standard
1017
1017
1018 These, by default, are only available under Unix-like operating systems.
1018 These, by default, are only available under Unix-like operating systems.
1019 However, thanks to Gary Bishop's work, Windows XP/2k users can also benefit
1019 However, thanks to Gary Bishop's work, Windows XP/2k users can also benefit
1020 from them.
1020 from them.
1021 His readline library implements both GNU readline functionality and color
1021 His readline library implements both GNU readline functionality and color
1022 support, so that IPython under Windows XP/2k can be as friendly and powerful
1022 support, so that IPython under Windows XP/2k can be as friendly and powerful
1023 as under Unix-like environments.
1023 as under Unix-like environments.
1024 \layout Standard
1024 \layout Standard
1025
1025
1026 You can find Gary's tools at
1026 You can find Gary's tools at
1027 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/projects/uncpythontools}
1027 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/projects/uncpythontools}
1028
1028
1029 \end_inset
1029 \end_inset
1030
1030
1031 ; Gary's
1031 ; Gary's
1032 \family typewriter
1032 \family typewriter
1033 readline
1033 readline
1034 \family default
1034 \family default
1035 requires in turn the
1035 requires in turn the
1036 \family typewriter
1036 \family typewriter
1037 ctypes
1037 ctypes
1038 \family default
1038 \family default
1039 library by Thomas Heller, available at
1039 library by Thomas Heller, available at
1040 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/theller/ctypes}
1040 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/theller/ctypes}
1041
1041
1042 \end_inset
1042 \end_inset
1043
1043
1044 , and Mark Hammond's
1044 , and Mark Hammond's
1045 \family typewriter
1045 \family typewriter
1046 PyWin32
1046 PyWin32
1047 \family default
1047 \family default
1048 from
1048 from
1049 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/mhammond}
1049 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/mhammond}
1050
1050
1051 \end_inset
1051 \end_inset
1052
1052
1053 (
1053 (
1054 \family typewriter
1054 \family typewriter
1055 PyWin32
1055 PyWin32
1056 \family default
1056 \family default
1057 is great for anything Windows-related anyway, so you might as well get
1057 is great for anything Windows-related anyway, so you might as well get
1058 it).
1058 it).
1059 \layout Standard
1059 \layout Standard
1060
1060
1061 Under MS\SpecialChar ~
1061 Under MS\SpecialChar ~
1062 Windows, IPython will complain if it can not find this
1062 Windows, IPython will complain if it can not find this
1063 \family typewriter
1063 \family typewriter
1064 readline
1064 readline
1065 \family default
1065 \family default
1066 library at startup and any time the
1066 library at startup and any time the
1067 \family typewriter
1067 \family typewriter
1068 %colors
1068 %colors
1069 \family default
1069 \family default
1070 command is issued, so you can consider it to be a quasi-requirement.
1070 command is issued, so you can consider it to be a quasi-requirement.
1071 \layout Subsubsection
1071 \layout Subsubsection
1072
1072
1073 Installation procedure
1073 Installation procedure
1074 \layout Standard
1074 \layout Standard
1075
1075
1076 Once you have the above installed, from the IPython download directory grab
1076 Once you have the above installed, from the IPython download directory grab
1077 the
1077 the
1078 \family typewriter
1078 \family typewriter
1079 ipython-XXX.win32.exe
1079 ipython-XXX.win32.exe
1080 \family default
1080 \family default
1081 file, where
1081 file, where
1082 \family typewriter
1082 \family typewriter
1083 XXX
1083 XXX
1084 \family default
1084 \family default
1085 represents the version number.
1085 represents the version number.
1086 This is a regular windows executable installer, which you can simply double-cli
1086 This is a regular windows executable installer, which you can simply double-cli
1087 ck to install.
1087 ck to install.
1088 It will add an entry for IPython to your Start Menu, as well as registering
1088 It will add an entry for IPython to your Start Menu, as well as registering
1089 IPython in the Windows list of applications, so you can later uninstall
1089 IPython in the Windows list of applications, so you can later uninstall
1090 it from the Control Panel.
1090 it from the Control Panel.
1091
1091
1092 \layout Standard
1092 \layout Standard
1093
1093
1094 IPython tries to install the configuration information in a directory named
1094 IPython tries to install the configuration information in a directory named
1095
1095
1096 \family typewriter
1096 \family typewriter
1097 .ipython
1097 .ipython
1098 \family default
1098 \family default
1099 (
1099 (
1100 \family typewriter
1100 \family typewriter
1101 _ipython
1101 _ipython
1102 \family default
1102 \family default
1103 under Windows) located in your `home' directory.
1103 under Windows) located in your `home' directory.
1104 IPython sets this directory by looking for a
1104 IPython sets this directory by looking for a
1105 \family typewriter
1105 \family typewriter
1106 HOME
1106 HOME
1107 \family default
1107 \family default
1108 environment variable; if such a variable does not exist, it uses
1108 environment variable; if such a variable does not exist, it uses
1109 \family typewriter
1109 \family typewriter
1110 HOMEDRIVE
1110 HOMEDRIVE
1111 \backslash
1111 \backslash
1112 HOMEPATH
1112 HOMEPATH
1113 \family default
1113 \family default
1114 (these are always defined by Windows).
1114 (these are always defined by Windows).
1115 This typically gives something like
1115 This typically gives something like
1116 \family typewriter
1116 \family typewriter
1117 C:
1117 C:
1118 \backslash
1118 \backslash
1119 Documents and Settings
1119 Documents and Settings
1120 \backslash
1120 \backslash
1121 YourUserName
1121 YourUserName
1122 \family default
1122 \family default
1123 , but your local details may vary.
1123 , but your local details may vary.
1124 In this directory you will find all the files that configure IPython's
1124 In this directory you will find all the files that configure IPython's
1125 defaults, and you can put there your profiles and extensions.
1125 defaults, and you can put there your profiles and extensions.
1126 This directory is automatically added by IPython to
1126 This directory is automatically added by IPython to
1127 \family typewriter
1127 \family typewriter
1128 sys.path
1128 sys.path
1129 \family default
1129 \family default
1130 , so anything you place there can be found by
1130 , so anything you place there can be found by
1131 \family typewriter
1131 \family typewriter
1132 import
1132 import
1133 \family default
1133 \family default
1134 statements.
1134 statements.
1135 \layout Paragraph
1135 \layout Paragraph
1136
1136
1137 Upgrading
1137 Upgrading
1138 \layout Standard
1138 \layout Standard
1139
1139
1140 For an IPython upgrade, you should first uninstall the previous version.
1140 For an IPython upgrade, you should first uninstall the previous version.
1141 This will ensure that all files and directories (such as the documentation)
1141 This will ensure that all files and directories (such as the documentation)
1142 which carry embedded version strings in their names are properly removed.
1142 which carry embedded version strings in their names are properly removed.
1143 \layout Paragraph
1143 \layout Paragraph
1144
1144
1145 Manual installation under Win32
1145 Manual installation under Win32
1146 \layout Standard
1146 \layout Standard
1147
1147
1148 In case the automatic installer does not work for some reason, you can download
1148 In case the automatic installer does not work for some reason, you can download
1149 the
1149 the
1150 \family typewriter
1150 \family typewriter
1151 ipython-XXX.tar.gz
1151 ipython-XXX.tar.gz
1152 \family default
1152 \family default
1153 file, which contains the full IPython source distribution (the popular
1153 file, which contains the full IPython source distribution (the popular
1154 WinZip can read
1154 WinZip can read
1155 \family typewriter
1155 \family typewriter
1156 .tar.gz
1156 .tar.gz
1157 \family default
1157 \family default
1158 files).
1158 files).
1159 After uncompressing the archive, you can install it at a command terminal
1159 After uncompressing the archive, you can install it at a command terminal
1160 just like any other Python module, by using
1160 just like any other Python module, by using
1161 \family typewriter
1161 \family typewriter
1162 `python setup.py install'
1162 `python setup.py install'
1163 \family default
1163 \family default
1164 .
1164 .
1165
1165
1166 \layout Standard
1166 \layout Standard
1167
1167
1168 After the installation, run the supplied
1168 After the installation, run the supplied
1169 \family typewriter
1169 \family typewriter
1170 win32_manual_post_install.py
1170 win32_manual_post_install.py
1171 \family default
1171 \family default
1172 script, which creates the necessary Start Menu shortcuts for you.
1172 script, which creates the necessary Start Menu shortcuts for you.
1173 \layout Subsection
1173 \layout Subsection
1174
1174
1175
1175
1176 \begin_inset LatexCommand \label{sec:upgrade}
1176 \begin_inset LatexCommand \label{sec:upgrade}
1177
1177
1178 \end_inset
1178 \end_inset
1179
1179
1180 Upgrading from a previous version
1180 Upgrading from a previous version
1181 \layout Standard
1181 \layout Standard
1182
1182
1183 If you are upgrading from a previous version of IPython, after doing the
1183 If you are upgrading from a previous version of IPython, after doing the
1184 routine installation described above, you should call IPython with the
1184 routine installation described above, you should call IPython with the
1185
1185
1186 \family typewriter
1186 \family typewriter
1187 -upgrade
1187 -upgrade
1188 \family default
1188 \family default
1189 option the first time you run your new copy.
1189 option the first time you run your new copy.
1190 This will automatically update your configuration directory while preserving
1190 This will automatically update your configuration directory while preserving
1191 copies of your old files.
1191 copies of your old files.
1192 You can then later merge back any personal customizations you may have
1192 You can then later merge back any personal customizations you may have
1193 made into the new files.
1193 made into the new files.
1194 It is a good idea to do this as there may be new options available in the
1194 It is a good idea to do this as there may be new options available in the
1195 new configuration files which you will not have.
1195 new configuration files which you will not have.
1196 \layout Standard
1196 \layout Standard
1197
1197
1198 Under Windows, if you don't know how to call python scripts with arguments
1198 Under Windows, if you don't know how to call python scripts with arguments
1199 from a command line, simply delete the old config directory and IPython
1199 from a command line, simply delete the old config directory and IPython
1200 will make a new one.
1200 will make a new one.
1201 Win2k and WinXP users will find it in
1201 Win2k and WinXP users will find it in
1202 \family typewriter
1202 \family typewriter
1203 C:
1203 C:
1204 \backslash
1204 \backslash
1205 Documents and Settings
1205 Documents and Settings
1206 \backslash
1206 \backslash
1207 YourUserName
1207 YourUserName
1208 \backslash
1208 \backslash
1209 _ipython
1209 _ipython
1210 \family default
1210 \family default
1211 , and Win 9x users under
1211 , and Win 9x users under
1212 \family typewriter
1212 \family typewriter
1213 C:
1213 C:
1214 \backslash
1214 \backslash
1215 Program Files
1215 Program Files
1216 \backslash
1216 \backslash
1217 IPython
1217 IPython
1218 \backslash
1218 \backslash
1219 _ipython.
1219 _ipython.
1220 \layout Section
1220 \layout Section
1221
1221
1222
1222
1223 \begin_inset LatexCommand \label{sec:good_config}
1223 \begin_inset LatexCommand \label{sec:good_config}
1224
1224
1225 \end_inset
1225 \end_inset
1226
1226
1227
1227
1228 \begin_inset OptArg
1228 \begin_inset OptArg
1229 collapsed true
1229 collapsed true
1230
1230
1231 \layout Standard
1231 \layout Standard
1232
1232
1233 Initial configuration
1233 Initial configuration
1234 \begin_inset ERT
1234 \begin_inset ERT
1235 status Collapsed
1235 status Collapsed
1236
1236
1237 \layout Standard
1237 \layout Standard
1238
1238
1239 \backslash
1239 \backslash
1240 ldots
1240 ldots
1241 \end_inset
1241 \end_inset
1242
1242
1243
1243
1244 \end_inset
1244 \end_inset
1245
1245
1246 Initial configuration of your environment
1246 Initial configuration of your environment
1247 \layout Standard
1247 \layout Standard
1248
1248
1249 This section will help you set various things in your environment for your
1249 This section will help you set various things in your environment for your
1250 IPython sessions to be as efficient as possible.
1250 IPython sessions to be as efficient as possible.
1251 All of IPython's configuration information, along with several example
1251 All of IPython's configuration information, along with several example
1252 files, is stored in a directory named by default
1252 files, is stored in a directory named by default
1253 \family typewriter
1253 \family typewriter
1254 $HOME/.ipython
1254 $HOME/.ipython
1255 \family default
1255 \family default
1256 .
1256 .
1257 You can change this by defining the environment variable
1257 You can change this by defining the environment variable
1258 \family typewriter
1258 \family typewriter
1259 IPYTHONDIR
1259 IPYTHONDIR
1260 \family default
1260 \family default
1261 , or at runtime with the command line option
1261 , or at runtime with the command line option
1262 \family typewriter
1262 \family typewriter
1263 -ipythondir
1263 -ipythondir
1264 \family default
1264 \family default
1265 .
1265 .
1266 \layout Standard
1266 \layout Standard
1267
1267
1268 If all goes well, the first time you run IPython it should automatically
1268 If all goes well, the first time you run IPython it should automatically
1269 create a user copy of the config directory for you, based on its builtin
1269 create a user copy of the config directory for you, based on its builtin
1270 defaults.
1270 defaults.
1271 You can look at the files it creates to learn more about configuring the
1271 You can look at the files it creates to learn more about configuring the
1272 system.
1272 system.
1273 The main file you will modify to configure IPython's behavior is called
1273 The main file you will modify to configure IPython's behavior is called
1274
1274
1275 \family typewriter
1275 \family typewriter
1276 ipythonrc
1276 ipythonrc
1277 \family default
1277 \family default
1278 (with a
1278 (with a
1279 \family typewriter
1279 \family typewriter
1280 .ini
1280 .ini
1281 \family default
1281 \family default
1282 extension under Windows), included for reference in Sec.
1282 extension under Windows), included for reference in Sec.
1283
1283
1284 \begin_inset LatexCommand \ref{sec:ipytonrc-sample}
1284 \begin_inset LatexCommand \ref{sec:ipytonrc-sample}
1285
1285
1286 \end_inset
1286 \end_inset
1287
1287
1288 .
1288 .
1289 This file is very commented and has many variables you can change to suit
1289 This file is very commented and has many variables you can change to suit
1290 your taste, you can find more details in Sec.
1290 your taste, you can find more details in Sec.
1291
1291
1292 \begin_inset LatexCommand \ref{sec:customization}
1292 \begin_inset LatexCommand \ref{sec:customization}
1293
1293
1294 \end_inset
1294 \end_inset
1295
1295
1296 .
1296 .
1297 Here we discuss the basic things you will want to make sure things are
1297 Here we discuss the basic things you will want to make sure things are
1298 working properly from the beginning.
1298 working properly from the beginning.
1299 \layout Subsection
1299 \layout Subsection
1300
1300
1301
1301
1302 \begin_inset LatexCommand \label{sec:help-access}
1302 \begin_inset LatexCommand \label{sec:help-access}
1303
1303
1304 \end_inset
1304 \end_inset
1305
1305
1306 Access to the Python help system
1306 Access to the Python help system
1307 \layout Standard
1307 \layout Standard
1308
1308
1309 This is true for Python in general (not just for IPython): you should have
1309 This is true for Python in general (not just for IPython): you should have
1310 an environment variable called
1310 an environment variable called
1311 \family typewriter
1311 \family typewriter
1312 PYTHONDOCS
1312 PYTHONDOCS
1313 \family default
1313 \family default
1314 pointing to the directory where your HTML Python documentation lives.
1314 pointing to the directory where your HTML Python documentation lives.
1315 In my system it's
1315 In my system it's
1316 \family typewriter
1316 \family typewriter
1317 /usr/share/doc/python-docs-2.3.4/html
1317 /usr/share/doc/python-docs-2.3.4/html
1318 \family default
1318 \family default
1319 , check your local details or ask your systems administrator.
1319 , check your local details or ask your systems administrator.
1320
1320
1321 \layout Standard
1321 \layout Standard
1322
1322
1323 This is the directory which holds the HTML version of the Python manuals.
1323 This is the directory which holds the HTML version of the Python manuals.
1324 Unfortunately it seems that different Linux distributions package these
1324 Unfortunately it seems that different Linux distributions package these
1325 files differently, so you may have to look around a bit.
1325 files differently, so you may have to look around a bit.
1326 Below I show the contents of this directory on my system for reference:
1326 Below I show the contents of this directory on my system for reference:
1327 \layout Standard
1327 \layout Standard
1328
1328
1329
1329
1330 \family typewriter
1330 \family typewriter
1331 [html]> ls
1331 [html]> ls
1332 \newline
1332 \newline
1333 about.dat acks.html dist/ ext/ index.html lib/ modindex.html stdabout.dat tut/
1333 about.dat acks.html dist/ ext/ index.html lib/ modindex.html stdabout.dat tut/
1334 about.html api/ doc/ icons/ inst/ mac/ ref/ style.css
1334 about.html api/ doc/ icons/ inst/ mac/ ref/ style.css
1335 \layout Standard
1335 \layout Standard
1336
1336
1337 You should really make sure this variable is correctly set so that Python's
1337 You should really make sure this variable is correctly set so that Python's
1338 pydoc-based help system works.
1338 pydoc-based help system works.
1339 It is a powerful and convenient system with full access to the Python manuals
1339 It is a powerful and convenient system with full access to the Python manuals
1340 and all modules accessible to you.
1340 and all modules accessible to you.
1341 \layout Standard
1341 \layout Standard
1342
1342
1343 Under Windows it seems that pydoc finds the documentation automatically,
1343 Under Windows it seems that pydoc finds the documentation automatically,
1344 so no extra setup appears necessary.
1344 so no extra setup appears necessary.
1345 \layout Subsection
1345 \layout Subsection
1346
1346
1347 Editor
1347 Editor
1348 \layout Standard
1348 \layout Standard
1349
1349
1350 The
1350 The
1351 \family typewriter
1351 \family typewriter
1352 %edit
1352 %edit
1353 \family default
1353 \family default
1354 command (and its alias
1354 command (and its alias
1355 \family typewriter
1355 \family typewriter
1356 %ed
1356 %ed
1357 \family default
1357 \family default
1358 ) will invoke the editor set in your environment as
1358 ) will invoke the editor set in your environment as
1359 \family typewriter
1359 \family typewriter
1360 EDITOR
1360 EDITOR
1361 \family default
1361 \family default
1362 .
1362 .
1363 If this variable is not set, it will default to
1363 If this variable is not set, it will default to
1364 \family typewriter
1364 \family typewriter
1365 vi
1365 vi
1366 \family default
1366 \family default
1367 under Linux/Unix and to
1367 under Linux/Unix and to
1368 \family typewriter
1368 \family typewriter
1369 notepad
1369 notepad
1370 \family default
1370 \family default
1371 under Windows.
1371 under Windows.
1372 You may want to set this variable properly and to a lightweight editor
1372 You may want to set this variable properly and to a lightweight editor
1373 which doesn't take too long to start (that is, something other than a new
1373 which doesn't take too long to start (that is, something other than a new
1374 instance of
1374 instance of
1375 \family typewriter
1375 \family typewriter
1376 Emacs
1376 Emacs
1377 \family default
1377 \family default
1378 ).
1378 ).
1379 This way you can edit multi-line code quickly and with the power of a real
1379 This way you can edit multi-line code quickly and with the power of a real
1380 editor right inside IPython.
1380 editor right inside IPython.
1381
1381
1382 \layout Standard
1382 \layout Standard
1383
1383
1384 If you are a dedicated
1384 If you are a dedicated
1385 \family typewriter
1385 \family typewriter
1386 Emacs
1386 Emacs
1387 \family default
1387 \family default
1388 user, you should set up the
1388 user, you should set up the
1389 \family typewriter
1389 \family typewriter
1390 Emacs
1390 Emacs
1391 \family default
1391 \family default
1392 server so that new requests are handled by the original process.
1392 server so that new requests are handled by the original process.
1393 This means that almost no time is spent in handling the request (assuming
1393 This means that almost no time is spent in handling the request (assuming
1394 an
1394 an
1395 \family typewriter
1395 \family typewriter
1396 Emacs
1396 Emacs
1397 \family default
1397 \family default
1398 process is already running).
1398 process is already running).
1399 For this to work, you need to set your
1399 For this to work, you need to set your
1400 \family typewriter
1400 \family typewriter
1401 EDITOR
1401 EDITOR
1402 \family default
1402 \family default
1403 environment variable to
1403 environment variable to
1404 \family typewriter
1404 \family typewriter
1405 'emacsclient'
1405 'emacsclient'
1406 \family default
1406 \family default
1407 .
1407 .
1408
1408
1409 \family typewriter
1409 \family typewriter
1410
1410
1411 \family default
1411 \family default
1412 The code below, supplied by Francois Pinard, can then be used in your
1412 The code below, supplied by Francois Pinard, can then be used in your
1413 \family typewriter
1413 \family typewriter
1414 .emacs
1414 .emacs
1415 \family default
1415 \family default
1416 file to enable the server:
1416 file to enable the server:
1417 \layout Standard
1417 \layout Standard
1418
1418
1419
1419
1420 \family typewriter
1420 \family typewriter
1421 (defvar server-buffer-clients)
1421 (defvar server-buffer-clients)
1422 \newline
1422 \newline
1423 (when (and (fboundp 'server-start) (string-equal (getenv "TERM") 'xterm))
1423 (when (and (fboundp 'server-start) (string-equal (getenv "TERM") 'xterm))
1424 \newline
1424 \newline
1425
1425
1426 \begin_inset ERT
1426 \begin_inset ERT
1427 status Collapsed
1427 status Collapsed
1428
1428
1429 \layout Standard
1429 \layout Standard
1430
1430
1431 \backslash
1431 \backslash
1432 hspace*{0mm}
1432 hspace*{0mm}
1433 \end_inset
1433 \end_inset
1434
1434
1435 \SpecialChar ~
1435 \SpecialChar ~
1436 \SpecialChar ~
1436 \SpecialChar ~
1437 (server-start)
1437 (server-start)
1438 \newline
1438 \newline
1439
1439
1440 \begin_inset ERT
1440 \begin_inset ERT
1441 status Collapsed
1441 status Collapsed
1442
1442
1443 \layout Standard
1443 \layout Standard
1444
1444
1445 \backslash
1445 \backslash
1446 hspace*{0mm}
1446 hspace*{0mm}
1447 \end_inset
1447 \end_inset
1448
1448
1449 \SpecialChar ~
1449 \SpecialChar ~
1450 \SpecialChar ~
1450 \SpecialChar ~
1451 (defun fp-kill-server-with-buffer-routine ()
1451 (defun fp-kill-server-with-buffer-routine ()
1452 \newline
1452 \newline
1453
1453
1454 \begin_inset ERT
1454 \begin_inset ERT
1455 status Collapsed
1455 status Collapsed
1456
1456
1457 \layout Standard
1457 \layout Standard
1458
1458
1459 \backslash
1459 \backslash
1460 hspace*{0mm}
1460 hspace*{0mm}
1461 \end_inset
1461 \end_inset
1462
1462
1463 \SpecialChar ~
1463 \SpecialChar ~
1464 \SpecialChar ~
1464 \SpecialChar ~
1465 \SpecialChar ~
1465 \SpecialChar ~
1466 \SpecialChar ~
1466 \SpecialChar ~
1467 (and server-buffer-clients (server-done)))
1467 (and server-buffer-clients (server-done)))
1468 \newline
1468 \newline
1469
1469
1470 \begin_inset ERT
1470 \begin_inset ERT
1471 status Collapsed
1471 status Collapsed
1472
1472
1473 \layout Standard
1473 \layout Standard
1474
1474
1475 \backslash
1475 \backslash
1476 hspace*{0mm}
1476 hspace*{0mm}
1477 \end_inset
1477 \end_inset
1478
1478
1479 \SpecialChar ~
1479 \SpecialChar ~
1480 \SpecialChar ~
1480 \SpecialChar ~
1481 (add-hook 'kill-buffer-hook 'fp-kill-server-with-buffer-routine))
1481 (add-hook 'kill-buffer-hook 'fp-kill-server-with-buffer-routine))
1482 \layout Standard
1482 \layout Standard
1483
1483
1484 You can also set the value of this editor via the commmand-line option '-
1484 You can also set the value of this editor via the commmand-line option '-
1485 \family typewriter
1485 \family typewriter
1486 editor'
1486 editor'
1487 \family default
1487 \family default
1488 or in your
1488 or in your
1489 \family typewriter
1489 \family typewriter
1490 ipythonrc
1490 ipythonrc
1491 \family default
1491 \family default
1492 file.
1492 file.
1493 This is useful if you wish to use specifically for IPython an editor different
1493 This is useful if you wish to use specifically for IPython an editor different
1494 from your typical default (and for Windows users who tend to use fewer
1494 from your typical default (and for Windows users who tend to use fewer
1495 environment variables).
1495 environment variables).
1496 \layout Subsection
1496 \layout Subsection
1497
1497
1498 Color
1498 Color
1499 \layout Standard
1499 \layout Standard
1500
1500
1501 The default IPython configuration has most bells and whistles turned on
1501 The default IPython configuration has most bells and whistles turned on
1502 (they're pretty safe).
1502 (they're pretty safe).
1503 But there's one that
1503 But there's one that
1504 \emph on
1504 \emph on
1505 may
1505 may
1506 \emph default
1506 \emph default
1507 cause problems on some systems: the use of color on screen for displaying
1507 cause problems on some systems: the use of color on screen for displaying
1508 information.
1508 information.
1509 This is very useful, since IPython can show prompts and exception tracebacks
1509 This is very useful, since IPython can show prompts and exception tracebacks
1510 with various colors, display syntax-highlighted source code, and in general
1510 with various colors, display syntax-highlighted source code, and in general
1511 make it easier to visually parse information.
1511 make it easier to visually parse information.
1512 \layout Standard
1512 \layout Standard
1513
1513
1514 The following terminals seem to handle the color sequences fine:
1514 The following terminals seem to handle the color sequences fine:
1515 \layout Itemize
1515 \layout Itemize
1516
1516
1517 Linux main text console, KDE Konsole, Gnome Terminal, E-term, rxvt, xterm.
1517 Linux main text console, KDE Konsole, Gnome Terminal, E-term, rxvt, xterm.
1518 \layout Itemize
1518 \layout Itemize
1519
1519
1520 CDE terminal (tested under Solaris).
1520 CDE terminal (tested under Solaris).
1521 This one boldfaces light colors.
1521 This one boldfaces light colors.
1522 \layout Itemize
1522 \layout Itemize
1523
1523
1524 (X)Emacs buffers.
1524 (X)Emacs buffers.
1525 See sec.
1525 See sec.
1526 \begin_inset LatexCommand \ref{sec:emacs}
1526 \begin_inset LatexCommand \ref{sec:emacs}
1527
1527
1528 \end_inset
1528 \end_inset
1529
1529
1530 for more details on using IPython with (X)Emacs.
1530 for more details on using IPython with (X)Emacs.
1531 \layout Itemize
1531 \layout Itemize
1532
1532
1533 A Windows (XP/2k) command prompt
1533 A Windows (XP/2k) command prompt
1534 \emph on
1534 \emph on
1535 with Gary Bishop's support extensions
1535 with Gary Bishop's support extensions
1536 \emph default
1536 \emph default
1537 .
1537 .
1538 Gary's extensions are discussed in Sec.\SpecialChar ~
1538 Gary's extensions are discussed in Sec.\SpecialChar ~
1539
1539
1540 \begin_inset LatexCommand \ref{sub:Under-Windows}
1540 \begin_inset LatexCommand \ref{sub:Under-Windows}
1541
1541
1542 \end_inset
1542 \end_inset
1543
1543
1544 .
1544 .
1545 \layout Itemize
1545 \layout Itemize
1546
1546
1547 A Windows (XP/2k) CygWin shell.
1547 A Windows (XP/2k) CygWin shell.
1548 Although some users have reported problems; it is not clear whether there
1548 Although some users have reported problems; it is not clear whether there
1549 is an issue for everyone or only under specific configurations.
1549 is an issue for everyone or only under specific configurations.
1550 If you have full color support under cygwin, please post to the IPython
1550 If you have full color support under cygwin, please post to the IPython
1551 mailing list so this issue can be resolved for all users.
1551 mailing list so this issue can be resolved for all users.
1552 \layout Standard
1552 \layout Standard
1553
1553
1554 These have shown problems:
1554 These have shown problems:
1555 \layout Itemize
1555 \layout Itemize
1556
1556
1557 Windows command prompt in WinXP/2k logged into a Linux machine via telnet
1557 Windows command prompt in WinXP/2k logged into a Linux machine via telnet
1558 or ssh.
1558 or ssh.
1559 \layout Itemize
1559 \layout Itemize
1560
1560
1561 Windows native command prompt in WinXP/2k,
1561 Windows native command prompt in WinXP/2k,
1562 \emph on
1562 \emph on
1563 without
1563 without
1564 \emph default
1564 \emph default
1565 Gary Bishop's extensions.
1565 Gary Bishop's extensions.
1566 Once Gary's readline library is installed, the normal WinXP/2k command
1566 Once Gary's readline library is installed, the normal WinXP/2k command
1567 prompt works perfectly.
1567 prompt works perfectly.
1568 \layout Standard
1568 \layout Standard
1569
1569
1570 Currently the following color schemes are available:
1570 Currently the following color schemes are available:
1571 \layout Itemize
1571 \layout Itemize
1572
1572
1573
1573
1574 \family typewriter
1574 \family typewriter
1575 NoColor
1575 NoColor
1576 \family default
1576 \family default
1577 : uses no color escapes at all (all escapes are empty
1577 : uses no color escapes at all (all escapes are empty
1578 \begin_inset Quotes eld
1578 \begin_inset Quotes eld
1579 \end_inset
1579 \end_inset
1580
1580
1581
1581
1582 \begin_inset Quotes eld
1582 \begin_inset Quotes eld
1583 \end_inset
1583 \end_inset
1584
1584
1585 strings).
1585 strings).
1586 This 'scheme' is thus fully safe to use in any terminal.
1586 This 'scheme' is thus fully safe to use in any terminal.
1587 \layout Itemize
1587 \layout Itemize
1588
1588
1589
1589
1590 \family typewriter
1590 \family typewriter
1591 Linux
1591 Linux
1592 \family default
1592 \family default
1593 : works well in Linux console type environments: dark background with light
1593 : works well in Linux console type environments: dark background with light
1594 fonts.
1594 fonts.
1595 It uses bright colors for information, so it is difficult to read if you
1595 It uses bright colors for information, so it is difficult to read if you
1596 have a light colored background.
1596 have a light colored background.
1597 \layout Itemize
1597 \layout Itemize
1598
1598
1599
1599
1600 \family typewriter
1600 \family typewriter
1601 LightBG
1601 LightBG
1602 \family default
1602 \family default
1603 : the basic colors are similar to those in the
1603 : the basic colors are similar to those in the
1604 \family typewriter
1604 \family typewriter
1605 Linux
1605 Linux
1606 \family default
1606 \family default
1607 scheme but darker.
1607 scheme but darker.
1608 It is easy to read in terminals with light backgrounds.
1608 It is easy to read in terminals with light backgrounds.
1609 \layout Standard
1609 \layout Standard
1610
1610
1611 IPython uses colors for two main groups of things: prompts and tracebacks
1611 IPython uses colors for two main groups of things: prompts and tracebacks
1612 which are directly printed to the terminal, and the object introspection
1612 which are directly printed to the terminal, and the object introspection
1613 system which passes large sets of data through a pager.
1613 system which passes large sets of data through a pager.
1614 \layout Subsubsection
1614 \layout Subsubsection
1615
1615
1616 Input/Output prompts and exception tracebacks
1616 Input/Output prompts and exception tracebacks
1617 \layout Standard
1617 \layout Standard
1618
1618
1619 You can test whether the colored prompts and tracebacks work on your system
1619 You can test whether the colored prompts and tracebacks work on your system
1620 interactively by typing
1620 interactively by typing
1621 \family typewriter
1621 \family typewriter
1622 '%colors Linux'
1622 '%colors Linux'
1623 \family default
1623 \family default
1624 at the prompt (use '
1624 at the prompt (use '
1625 \family typewriter
1625 \family typewriter
1626 %colors LightBG'
1626 %colors LightBG'
1627 \family default
1627 \family default
1628 if your terminal has a light background).
1628 if your terminal has a light background).
1629 If the input prompt shows garbage like:
1629 If the input prompt shows garbage like:
1630 \newline
1630 \newline
1631
1631
1632 \family typewriter
1632 \family typewriter
1633 [0;32mIn [[1;32m1[0;32m]: [0;00m
1633 [0;32mIn [[1;32m1[0;32m]: [0;00m
1634 \family default
1634 \family default
1635
1635
1636 \newline
1636 \newline
1637 instead of (in color) something like:
1637 instead of (in color) something like:
1638 \newline
1638 \newline
1639
1639
1640 \family typewriter
1640 \family typewriter
1641 In [1]:
1641 In [1]:
1642 \family default
1642 \family default
1643
1643
1644 \newline
1644 \newline
1645 this means that your terminal doesn't properly handle color escape sequences.
1645 this means that your terminal doesn't properly handle color escape sequences.
1646 You can go to a 'no color' mode by typing '
1646 You can go to a 'no color' mode by typing '
1647 \family typewriter
1647 \family typewriter
1648 %colors NoColor
1648 %colors NoColor
1649 \family default
1649 \family default
1650 '.
1650 '.
1651
1651
1652 \layout Standard
1652 \layout Standard
1653
1653
1654 You can try using a different terminal emulator program.
1654 You can try using a different terminal emulator program.
1655 To permanently set your color preferences, edit the file
1655 To permanently set your color preferences, edit the file
1656 \family typewriter
1656 \family typewriter
1657 $HOME/.ipython/ipythonrc
1657 $HOME/.ipython/ipythonrc
1658 \family default
1658 \family default
1659 and set the
1659 and set the
1660 \family typewriter
1660 \family typewriter
1661 colors
1661 colors
1662 \family default
1662 \family default
1663 option to the desired value.
1663 option to the desired value.
1664 \layout Subsubsection
1664 \layout Subsubsection
1665
1665
1666 Object details (types, docstrings, source code, etc.)
1666 Object details (types, docstrings, source code, etc.)
1667 \layout Standard
1667 \layout Standard
1668
1668
1669 IPython has a set of special functions for studying the objects you are
1669 IPython has a set of special functions for studying the objects you are
1670 working with, discussed in detail in Sec.
1670 working with, discussed in detail in Sec.
1671
1671
1672 \begin_inset LatexCommand \ref{sec:dyn-object-info}
1672 \begin_inset LatexCommand \ref{sec:dyn-object-info}
1673
1673
1674 \end_inset
1674 \end_inset
1675
1675
1676 .
1676 .
1677 But this system relies on passing information which is longer than your
1677 But this system relies on passing information which is longer than your
1678 screen through a data pager, such as the common Unix
1678 screen through a data pager, such as the common Unix
1679 \family typewriter
1679 \family typewriter
1680 less
1680 less
1681 \family default
1681 \family default
1682 and
1682 and
1683 \family typewriter
1683 \family typewriter
1684 more
1684 more
1685 \family default
1685 \family default
1686 programs.
1686 programs.
1687 In order to be able to see this information in color, your pager needs
1687 In order to be able to see this information in color, your pager needs
1688 to be properly configured.
1688 to be properly configured.
1689 I strongly recommend using
1689 I strongly recommend using
1690 \family typewriter
1690 \family typewriter
1691 less
1691 less
1692 \family default
1692 \family default
1693 instead of
1693 instead of
1694 \family typewriter
1694 \family typewriter
1695 more
1695 more
1696 \family default
1696 \family default
1697 , as it seems that
1697 , as it seems that
1698 \family typewriter
1698 \family typewriter
1699 more
1699 more
1700 \family default
1700 \family default
1701 simply can not understand colored text correctly.
1701 simply can not understand colored text correctly.
1702 \layout Standard
1702 \layout Standard
1703
1703
1704 In order to configure
1704 In order to configure
1705 \family typewriter
1705 \family typewriter
1706 less
1706 less
1707 \family default
1707 \family default
1708 as your default pager, do the following:
1708 as your default pager, do the following:
1709 \layout Enumerate
1709 \layout Enumerate
1710
1710
1711 Set the environment
1711 Set the environment
1712 \family typewriter
1712 \family typewriter
1713 PAGER
1713 PAGER
1714 \family default
1714 \family default
1715 variable to
1715 variable to
1716 \family typewriter
1716 \family typewriter
1717 less
1717 less
1718 \family default
1718 \family default
1719 .
1719 .
1720 \layout Enumerate
1720 \layout Enumerate
1721
1721
1722 Set the environment
1722 Set the environment
1723 \family typewriter
1723 \family typewriter
1724 LESS
1724 LESS
1725 \family default
1725 \family default
1726 variable to
1726 variable to
1727 \family typewriter
1727 \family typewriter
1728 -r
1728 -r
1729 \family default
1729 \family default
1730 (plus any other options you always want to pass to
1730 (plus any other options you always want to pass to
1731 \family typewriter
1731 \family typewriter
1732 less
1732 less
1733 \family default
1733 \family default
1734 by default).
1734 by default).
1735 This tells
1735 This tells
1736 \family typewriter
1736 \family typewriter
1737 less
1737 less
1738 \family default
1738 \family default
1739 to properly interpret control sequences, which is how color information
1739 to properly interpret control sequences, which is how color information
1740 is given to your terminal.
1740 is given to your terminal.
1741 \layout Standard
1741 \layout Standard
1742
1742
1743 For the
1743 For the
1744 \family typewriter
1744 \family typewriter
1745 csh
1745 csh
1746 \family default
1746 \family default
1747 or
1747 or
1748 \family typewriter
1748 \family typewriter
1749 tcsh
1749 tcsh
1750 \family default
1750 \family default
1751 shells, add to your
1751 shells, add to your
1752 \family typewriter
1752 \family typewriter
1753 ~/.cshrc
1753 ~/.cshrc
1754 \family default
1754 \family default
1755 file the lines:
1755 file the lines:
1756 \layout Standard
1756 \layout Standard
1757
1757
1758
1758
1759 \family typewriter
1759 \family typewriter
1760 setenv PAGER less
1760 setenv PAGER less
1761 \newline
1761 \newline
1762 setenv LESS -r
1762 setenv LESS -r
1763 \layout Standard
1763 \layout Standard
1764
1764
1765 There is similar syntax for other Unix shells, look at your system documentation
1765 There is similar syntax for other Unix shells, look at your system documentation
1766 for details.
1766 for details.
1767 \layout Standard
1767 \layout Standard
1768
1768
1769 If you are on a system which lacks proper data pagers (such as Windows),
1769 If you are on a system which lacks proper data pagers (such as Windows),
1770 IPython will use a very limited builtin pager.
1770 IPython will use a very limited builtin pager.
1771 \layout Subsection
1771 \layout Subsection
1772
1772
1773
1773
1774 \begin_inset LatexCommand \label{sec:emacs}
1774 \begin_inset LatexCommand \label{sec:emacs}
1775
1775
1776 \end_inset
1776 \end_inset
1777
1777
1778 (X)Emacs configuration
1778 (X)Emacs configuration
1779 \layout Standard
1779 \layout Standard
1780
1780
1781 Thanks to the work of Alexander Schmolck and Prabhu Ramachandran, currently
1781 Thanks to the work of Alexander Schmolck and Prabhu Ramachandran, currently
1782 (X)Emacs and IPython get along very well.
1782 (X)Emacs and IPython get along very well.
1783
1783
1784 \layout Standard
1784 \layout Standard
1785
1785
1786
1786
1787 \series bold
1787 \series bold
1788 Important note:
1788 Important note:
1789 \series default
1789 \series default
1790 You will need to use a recent enough version of
1790 You will need to use a recent enough version of
1791 \family typewriter
1791 \family typewriter
1792 python-mode.el
1792 python-mode.el
1793 \family default
1793 \family default
1794 , along with the file
1794 , along with the file
1795 \family typewriter
1795 \family typewriter
1796 ipython.el
1796 ipython.el
1797 \family default
1797 \family default
1798 .
1798 .
1799 You can check that the version you have of
1799 You can check that the version you have of
1800 \family typewriter
1800 \family typewriter
1801 python-mode.el
1801 python-mode.el
1802 \family default
1802 \family default
1803 is new enough by either looking at the revision number in the file itself,
1803 is new enough by either looking at the revision number in the file itself,
1804 or asking for it in (X)Emacs via
1804 or asking for it in (X)Emacs via
1805 \family typewriter
1805 \family typewriter
1806 M-x py-version
1806 M-x py-version
1807 \family default
1807 \family default
1808 .
1808 .
1809 Versions 4.68 and newer contain the necessary fixes for proper IPython support.
1809 Versions 4.68 and newer contain the necessary fixes for proper IPython support.
1810 \layout Standard
1810 \layout Standard
1811
1811
1812 The file
1812 The file
1813 \family typewriter
1813 \family typewriter
1814 ipython.el
1814 ipython.el
1815 \family default
1815 \family default
1816 is included with the IPython distribution, in the documentation directory
1816 is included with the IPython distribution, in the documentation directory
1817 (where this manual resides in PDF and HTML formats).
1817 (where this manual resides in PDF and HTML formats).
1818 \layout Standard
1818 \layout Standard
1819
1819
1820 Once you put these files in your Emacs path, all you need in your
1820 Once you put these files in your Emacs path, all you need in your
1821 \family typewriter
1821 \family typewriter
1822 .emacs
1822 .emacs
1823 \family default
1823 \family default
1824 file is:
1824 file is:
1825 \layout Standard
1825 \layout Standard
1826
1826
1827
1827
1828 \family typewriter
1828 \family typewriter
1829 (require 'ipython)
1829 (require 'ipython)
1830 \layout Standard
1830 \layout Standard
1831
1831
1832 This should give you full support for executing code snippets via IPython,
1832 This should give you full support for executing code snippets via IPython,
1833 opening IPython as your Python shell via
1833 opening IPython as your Python shell via
1834 \family typewriter
1834 \family typewriter
1835 C-c\SpecialChar ~
1835 C-c\SpecialChar ~
1836 !
1836 !
1837 \family default
1837 \family default
1838 , etc.
1838 , etc.
1839
1839
1840 \layout Subsubsection*
1840 \layout Subsubsection*
1841
1841
1842 Notes
1842 Notes
1843 \layout Itemize
1843 \layout Itemize
1844
1844
1845 There is one caveat you should be aware of: you must start the IPython shell
1845 There is one caveat you should be aware of: you must start the IPython shell
1846
1846
1847 \emph on
1847 \emph on
1848 before
1848 before
1849 \emph default
1849 \emph default
1850 attempting to execute any code regions via
1850 attempting to execute any code regions via
1851 \family typewriter
1851 \family typewriter
1852 C-c\SpecialChar ~
1852 C-c\SpecialChar ~
1853 |
1853 |
1854 \family default
1854 \family default
1855 .
1855 .
1856 Simply type
1856 Simply type
1857 \family typewriter
1857 \family typewriter
1858 C-c\SpecialChar ~
1858 C-c\SpecialChar ~
1859 !
1859 !
1860 \family default
1860 \family default
1861 to start IPython before passing any code regions to the interpreter, and
1861 to start IPython before passing any code regions to the interpreter, and
1862 you shouldn't experience any problems.
1862 you shouldn't experience any problems.
1863 \newline
1863 \newline
1864 This is due to a bug in Python itself, which has been fixed for Python 2.3,
1864 This is due to a bug in Python itself, which has been fixed for Python 2.3,
1865 but exists as of Python 2.2.2 (reported as SF bug [ 737947 ]).
1865 but exists as of Python 2.2.2 (reported as SF bug [ 737947 ]).
1866 \layout Itemize
1866 \layout Itemize
1867
1867
1868 The (X)Emacs support is maintained by Alexander Schmolck, so all comments/reques
1868 The (X)Emacs support is maintained by Alexander Schmolck, so all comments/reques
1869 ts should be directed to him through the IPython mailing lists.
1869 ts should be directed to him through the IPython mailing lists.
1870
1870
1871 \layout Itemize
1871 \layout Itemize
1872
1872
1873 This code is still somewhat experimental so it's a bit rough around the
1873 This code is still somewhat experimental so it's a bit rough around the
1874 edges (although in practice, it works quite well).
1874 edges (although in practice, it works quite well).
1875 \layout Itemize
1875 \layout Itemize
1876
1876
1877 Be aware that if you customize
1877 Be aware that if you customize
1878 \family typewriter
1878 \family typewriter
1879 py-python-command
1879 py-python-command
1880 \family default
1880 \family default
1881 previously, this value will override what
1881 previously, this value will override what
1882 \family typewriter
1882 \family typewriter
1883 ipython.el
1883 ipython.el
1884 \family default
1884 \family default
1885 does (because loading the customization variables comes later).
1885 does (because loading the customization variables comes later).
1886 \layout Section
1886 \layout Section
1887
1887
1888
1888
1889 \begin_inset LatexCommand \label{sec:quick_tips}
1889 \begin_inset LatexCommand \label{sec:quick_tips}
1890
1890
1891 \end_inset
1891 \end_inset
1892
1892
1893 Quick tips
1893 Quick tips
1894 \layout Standard
1894 \layout Standard
1895
1895
1896 IPython can be used as an improved replacement for the Python prompt, and
1896 IPython can be used as an improved replacement for the Python prompt, and
1897 for that you don't really need to read any more of this manual.
1897 for that you don't really need to read any more of this manual.
1898 But in this section we'll try to summarize a few tips on how to make the
1898 But in this section we'll try to summarize a few tips on how to make the
1899 most effective use of it for everyday Python development, highlighting
1899 most effective use of it for everyday Python development, highlighting
1900 things you might miss in the rest of the manual (which is getting long).
1900 things you might miss in the rest of the manual (which is getting long).
1901 We'll give references to parts in the manual which provide more detail
1901 We'll give references to parts in the manual which provide more detail
1902 when appropriate.
1902 when appropriate.
1903 \layout Standard
1903 \layout Standard
1904
1904
1905 The following article by Jeremy Jones provides an introductory tutorial
1905 The following article by Jeremy Jones provides an introductory tutorial
1906 about IPython:
1906 about IPython:
1907 \newline
1907 \newline
1908
1908
1909 \begin_inset LatexCommand \htmlurl{http://www.onlamp.com/pub/a/python/2005/01/27/ipython.html}
1909 \begin_inset LatexCommand \htmlurl{http://www.onlamp.com/pub/a/python/2005/01/27/ipython.html}
1910
1910
1911 \end_inset
1911 \end_inset
1912
1912
1913
1913
1914 \layout Itemize
1914 \layout Itemize
1915
1915
1916 The TAB key.
1916 The TAB key.
1917 TAB-completion, especially for attributes, is a convenient way to explore
1917 TAB-completion, especially for attributes, is a convenient way to explore
1918 the structure of any object you're dealing with.
1918 the structure of any object you're dealing with.
1919 Simply type
1919 Simply type
1920 \family typewriter
1920 \family typewriter
1921 object_name.<TAB>
1921 object_name.<TAB>
1922 \family default
1922 \family default
1923 and a list of the object's attributes will be printed (see sec.
1923 and a list of the object's attributes will be printed (see sec.
1924
1924
1925 \begin_inset LatexCommand \ref{sec:readline}
1925 \begin_inset LatexCommand \ref{sec:readline}
1926
1926
1927 \end_inset
1927 \end_inset
1928
1928
1929 for more).
1929 for more).
1930 Tab completion also works on file and directory names, which combined with
1930 Tab completion also works on file and directory names, which combined with
1931 IPython's alias system allows you to do from within IPython many of the
1931 IPython's alias system allows you to do from within IPython many of the
1932 things you normally would need the system shell for.
1932 things you normally would need the system shell for.
1933
1933
1934 \layout Itemize
1934 \layout Itemize
1935
1935
1936 Explore your objects.
1936 Explore your objects.
1937 Typing
1937 Typing
1938 \family typewriter
1938 \family typewriter
1939 object_name?
1939 object_name?
1940 \family default
1940 \family default
1941 will print all sorts of details about any object, including docstrings,
1941 will print all sorts of details about any object, including docstrings,
1942 function definition lines (for call arguments) and constructor details
1942 function definition lines (for call arguments) and constructor details
1943 for classes.
1943 for classes.
1944 The magic commands
1944 The magic commands
1945 \family typewriter
1945 \family typewriter
1946 %pdoc
1946 %pdoc
1947 \family default
1947 \family default
1948 ,
1948 ,
1949 \family typewriter
1949 \family typewriter
1950 %pdef
1950 %pdef
1951 \family default
1951 \family default
1952 ,
1952 ,
1953 \family typewriter
1953 \family typewriter
1954 %psource
1954 %psource
1955 \family default
1955 \family default
1956 and
1956 and
1957 \family typewriter
1957 \family typewriter
1958 %pfile
1958 %pfile
1959 \family default
1959 \family default
1960 will respectively print the docstring, function definition line, full source
1960 will respectively print the docstring, function definition line, full source
1961 code and the complete file for any object (when they can be found).
1961 code and the complete file for any object (when they can be found).
1962 If automagic is on (it is by default), you don't need to type the '
1962 If automagic is on (it is by default), you don't need to type the '
1963 \family typewriter
1963 \family typewriter
1964 %
1964 %
1965 \family default
1965 \family default
1966 ' explicitly.
1966 ' explicitly.
1967 See sec.
1967 See sec.
1968
1968
1969 \begin_inset LatexCommand \ref{sec:dyn-object-info}
1969 \begin_inset LatexCommand \ref{sec:dyn-object-info}
1970
1970
1971 \end_inset
1971 \end_inset
1972
1972
1973 for more.
1973 for more.
1974 \layout Itemize
1974 \layout Itemize
1975
1975
1976 The
1976 The
1977 \family typewriter
1977 \family typewriter
1978 %run
1978 %run
1979 \family default
1979 \family default
1980 magic command allows you to run any python script and load all of its data
1980 magic command allows you to run any python script and load all of its data
1981 directly into the interactive namespace.
1981 directly into the interactive namespace.
1982 Since the file is re-read from disk each time, changes you make to it are
1982 Since the file is re-read from disk each time, changes you make to it are
1983 reflected immediately (in contrast to the behavior of
1983 reflected immediately (in contrast to the behavior of
1984 \family typewriter
1984 \family typewriter
1985 import
1985 import
1986 \family default
1986 \family default
1987 ).
1987 ).
1988 I rarely use
1988 I rarely use
1989 \family typewriter
1989 \family typewriter
1990 import
1990 import
1991 \family default
1991 \family default
1992 for code I am testing, relying on
1992 for code I am testing, relying on
1993 \family typewriter
1993 \family typewriter
1994 %run
1994 %run
1995 \family default
1995 \family default
1996 instead.
1996 instead.
1997 See sec.
1997 See sec.
1998
1998
1999 \begin_inset LatexCommand \ref{sec:magic}
1999 \begin_inset LatexCommand \ref{sec:magic}
2000
2000
2001 \end_inset
2001 \end_inset
2002
2002
2003 for more on this and other magic commands, or type the name of any magic
2003 for more on this and other magic commands, or type the name of any magic
2004 command and ? to get details on it.
2004 command and ? to get details on it.
2005 See also sec.
2005 See also sec.
2006
2006
2007 \begin_inset LatexCommand \ref{sec:dreload}
2007 \begin_inset LatexCommand \ref{sec:dreload}
2008
2008
2009 \end_inset
2009 \end_inset
2010
2010
2011 for a recursive reload command.
2011 for a recursive reload command.
2012 \newline
2012 \newline
2013
2013
2014 \family typewriter
2014 \family typewriter
2015 %run
2015 %run
2016 \family default
2016 \family default
2017 also has special flags for timing the execution of your scripts (
2017 also has special flags for timing the execution of your scripts (
2018 \family typewriter
2018 \family typewriter
2019 -t
2019 -t
2020 \family default
2020 \family default
2021 ) and for executing them under the control of either Python's
2021 ) and for executing them under the control of either Python's
2022 \family typewriter
2022 \family typewriter
2023 pdb
2023 pdb
2024 \family default
2024 \family default
2025 debugger (
2025 debugger (
2026 \family typewriter
2026 \family typewriter
2027 -d
2027 -d
2028 \family default
2028 \family default
2029 ) or profiler (
2029 ) or profiler (
2030 \family typewriter
2030 \family typewriter
2031 -p
2031 -p
2032 \family default
2032 \family default
2033 ).
2033 ).
2034 With all of these,
2034 With all of these,
2035 \family typewriter
2035 \family typewriter
2036 %run
2036 %run
2037 \family default
2037 \family default
2038 can be used as the main tool for efficient interactive development of code
2038 can be used as the main tool for efficient interactive development of code
2039 which you write in your editor of choice.
2039 which you write in your editor of choice.
2040 \layout Itemize
2040 \layout Itemize
2041
2041
2042 Use the Python debugger,
2042 Use the Python debugger,
2043 \family typewriter
2043 \family typewriter
2044 pdb
2044 pdb
2045 \family default
2045 \family default
2046
2046
2047 \begin_inset Foot
2047 \begin_inset Foot
2048 collapsed true
2048 collapsed true
2049
2049
2050 \layout Standard
2050 \layout Standard
2051
2051
2052 Thanks to Christian Hart and Matthew Arnison for the suggestions leading
2052 Thanks to Christian Hart and Matthew Arnison for the suggestions leading
2053 to IPython's improved debugger and profiler support.
2053 to IPython's improved debugger and profiler support.
2054 \end_inset
2054 \end_inset
2055
2055
2056 .
2056 .
2057 The
2057 The
2058 \family typewriter
2058 \family typewriter
2059 %pdb
2059 %pdb
2060 \family default
2060 \family default
2061 command allows you to toggle on and off the automatic invocation of the
2061 command allows you to toggle on and off the automatic invocation of the
2062 pdb debugger at any uncaught exception.
2062 pdb debugger at any uncaught exception.
2063 The advantage of this is that pdb starts
2063 The advantage of this is that pdb starts
2064 \emph on
2064 \emph on
2065 inside
2065 inside
2066 \emph default
2066 \emph default
2067 the function where the exception occurred, with all data still available.
2067 the function where the exception occurred, with all data still available.
2068 You can print variables, see code, execute statements and even walk up
2068 You can print variables, see code, execute statements and even walk up
2069 and down the call stack to track down the true source of the problem (which
2069 and down the call stack to track down the true source of the problem (which
2070 often is many layers in the stack above where the exception gets triggered).
2070 often is many layers in the stack above where the exception gets triggered).
2071 \newline
2071 \newline
2072 Running programs with
2072 Running programs with
2073 \family typewriter
2073 \family typewriter
2074 %run
2074 %run
2075 \family default
2075 \family default
2076 and pdb active can be an efficient to develop and debug code, in many cases
2076 and pdb active can be an efficient to develop and debug code, in many cases
2077 eliminating the need for
2077 eliminating the need for
2078 \family typewriter
2078 \family typewriter
2079 print
2079 print
2080 \family default
2080 \family default
2081 statements or external debugging tools.
2081 statements or external debugging tools.
2082 I often simply put a
2082 I often simply put a
2083 \family typewriter
2083 \family typewriter
2084 1/0
2084 1/0
2085 \family default
2085 \family default
2086 in a place where I want to take a look so that pdb gets called, quickly
2086 in a place where I want to take a look so that pdb gets called, quickly
2087 view whatever variables I need to or test various pieces of code and then
2087 view whatever variables I need to or test various pieces of code and then
2088 remove the
2088 remove the
2089 \family typewriter
2089 \family typewriter
2090 1/0
2090 1/0
2091 \family default
2091 \family default
2092 .
2092 .
2093 \newline
2093 \newline
2094 Note also that `
2094 Note also that `
2095 \family typewriter
2095 \family typewriter
2096 %run -d
2096 %run -d
2097 \family default
2097 \family default
2098 ' activates
2098 ' activates
2099 \family typewriter
2099 \family typewriter
2100 pdb
2100 pdb
2101 \family default
2101 \family default
2102 and automatically sets initial breakpoints for you to step through your
2102 and automatically sets initial breakpoints for you to step through your
2103 code, watch variables, etc.
2103 code, watch variables, etc.
2104 See Sec.\SpecialChar ~
2104 See Sec.\SpecialChar ~
2105
2105
2106 \begin_inset LatexCommand \ref{sec:cache_output}
2106 \begin_inset LatexCommand \ref{sec:cache_output}
2107
2107
2108 \end_inset
2108 \end_inset
2109
2109
2110 for details.
2110 for details.
2111 \layout Itemize
2111 \layout Itemize
2112
2112
2113 Use the output cache.
2113 Use the output cache.
2114 All output results are automatically stored in a global dictionary named
2114 All output results are automatically stored in a global dictionary named
2115
2115
2116 \family typewriter
2116 \family typewriter
2117 Out
2117 Out
2118 \family default
2118 \family default
2119 and variables named
2119 and variables named
2120 \family typewriter
2120 \family typewriter
2121 _1
2121 _1
2122 \family default
2122 \family default
2123 ,
2123 ,
2124 \family typewriter
2124 \family typewriter
2125 _2
2125 _2
2126 \family default
2126 \family default
2127 , etc.
2127 , etc.
2128 alias them.
2128 alias them.
2129 For example, the result of input line 4 is available either as
2129 For example, the result of input line 4 is available either as
2130 \family typewriter
2130 \family typewriter
2131 Out[4]
2131 Out[4]
2132 \family default
2132 \family default
2133 or as
2133 or as
2134 \family typewriter
2134 \family typewriter
2135 _4
2135 _4
2136 \family default
2136 \family default
2137 .
2137 .
2138 Additionally, three variables named
2138 Additionally, three variables named
2139 \family typewriter
2139 \family typewriter
2140 _
2140 _
2141 \family default
2141 \family default
2142 ,
2142 ,
2143 \family typewriter
2143 \family typewriter
2144 __
2144 __
2145 \family default
2145 \family default
2146 and
2146 and
2147 \family typewriter
2147 \family typewriter
2148 ___
2148 ___
2149 \family default
2149 \family default
2150 are always kept updated with the for the last three results.
2150 are always kept updated with the for the last three results.
2151 This allows you to recall any previous result and further use it for new
2151 This allows you to recall any previous result and further use it for new
2152 calculations.
2152 calculations.
2153 See Sec.\SpecialChar ~
2153 See Sec.\SpecialChar ~
2154
2154
2155 \begin_inset LatexCommand \ref{sec:cache_output}
2155 \begin_inset LatexCommand \ref{sec:cache_output}
2156
2156
2157 \end_inset
2157 \end_inset
2158
2158
2159 for more.
2159 for more.
2160 \layout Itemize
2160 \layout Itemize
2161
2161
2162 Put a '
2162 Put a '
2163 \family typewriter
2163 \family typewriter
2164 ;
2164 ;
2165 \family default
2165 \family default
2166 ' at the end of a line to supress the printing of output.
2166 ' at the end of a line to supress the printing of output.
2167 This is useful when doing calculations which generate long output you are
2167 This is useful when doing calculations which generate long output you are
2168 not interested in seeing.
2168 not interested in seeing.
2169 The
2169 The
2170 \family typewriter
2170 \family typewriter
2171 _*
2171 _*
2172 \family default
2172 \family default
2173 variables and the
2173 variables and the
2174 \family typewriter
2174 \family typewriter
2175 Out[]
2175 Out[]
2176 \family default
2176 \family default
2177 list do get updated with the contents of the output, even if it is not
2177 list do get updated with the contents of the output, even if it is not
2178 printed.
2178 printed.
2179 You can thus still access the generated results this way for further processing.
2179 You can thus still access the generated results this way for further processing.
2180 \layout Itemize
2180 \layout Itemize
2181
2181
2182 A similar system exists for caching input.
2182 A similar system exists for caching input.
2183 All input is stored in a global list called
2183 All input is stored in a global list called
2184 \family typewriter
2184 \family typewriter
2185 In
2185 In
2186 \family default
2186 \family default
2187 , so you can re-execute lines 22 through 28 plus line 34 by typing
2187 , so you can re-execute lines 22 through 28 plus line 34 by typing
2188 \family typewriter
2188 \family typewriter
2189 'exec In[22:29]+In[34]'
2189 'exec In[22:29]+In[34]'
2190 \family default
2190 \family default
2191 (using Python slicing notation).
2191 (using Python slicing notation).
2192 If you need to execute the same set of lines often, you can assign them
2192 If you need to execute the same set of lines often, you can assign them
2193 to a macro with the
2193 to a macro with the
2194 \family typewriter
2194 \family typewriter
2195 %macro
2195 %macro
2196 \family default
2196 \family default
2197
2197
2198 \family typewriter
2198 \family typewriter
2199 function.
2199 function.
2200
2200
2201 \family default
2201 \family default
2202 See sec.
2202 See sec.
2203
2203
2204 \begin_inset LatexCommand \ref{sec:cache_input}
2204 \begin_inset LatexCommand \ref{sec:cache_input}
2205
2205
2206 \end_inset
2206 \end_inset
2207
2207
2208 for more.
2208 for more.
2209 \layout Itemize
2209 \layout Itemize
2210
2210
2211 Use your input history.
2211 Use your input history.
2212 The
2212 The
2213 \family typewriter
2213 \family typewriter
2214 %hist
2214 %hist
2215 \family default
2215 \family default
2216 command can show you all previous input, without line numbers if desired
2216 command can show you all previous input, without line numbers if desired
2217 (option
2217 (option
2218 \family typewriter
2218 \family typewriter
2219 -n
2219 -n
2220 \family default
2220 \family default
2221 ) so you can directly copy and paste code either back in IPython or in a
2221 ) so you can directly copy and paste code either back in IPython or in a
2222 text editor.
2222 text editor.
2223 You can also save all your history by turning on logging via
2223 You can also save all your history by turning on logging via
2224 \family typewriter
2224 \family typewriter
2225 %logstart
2225 %logstart
2226 \family default
2226 \family default
2227 ; these logs can later be either reloaded as IPython sessions or used as
2227 ; these logs can later be either reloaded as IPython sessions or used as
2228 code for your programs.
2228 code for your programs.
2229 \layout Itemize
2229 \layout Itemize
2230
2230
2231 Define your own macros with
2231 Define your own macros with
2232 \family typewriter
2232 \family typewriter
2233 %macro
2233 %macro
2234 \family default
2234 \family default
2235 .
2235 .
2236 This can be useful for automating sequences of expressions when working
2236 This can be useful for automating sequences of expressions when working
2237 interactively.
2237 interactively.
2238 \layout Itemize
2238 \layout Itemize
2239
2239
2240 Define your own system aliases.
2240 Define your own system aliases.
2241 Even though IPython gives you access to your system shell via the
2241 Even though IPython gives you access to your system shell via the
2242 \family typewriter
2242 \family typewriter
2243 !
2243 !
2244 \family default
2244 \family default
2245 prefix, it is convenient to have aliases to the system commands you use
2245 prefix, it is convenient to have aliases to the system commands you use
2246 most often.
2246 most often.
2247 This allows you to work seamlessly from inside IPython with the same commands
2247 This allows you to work seamlessly from inside IPython with the same commands
2248 you are used to in your system shell.
2248 you are used to in your system shell.
2249 \newline
2249 \newline
2250 IPython comes with some pre-defined aliases and a complete system for changing
2250 IPython comes with some pre-defined aliases and a complete system for changing
2251 directories, both via a stack (see
2251 directories, both via a stack (see
2252 \family typewriter
2252 \family typewriter
2253 %pushd
2253 %pushd
2254 \family default
2254 \family default
2255 ,
2255 ,
2256 \family typewriter
2256 \family typewriter
2257 %popd
2257 %popd
2258 \family default
2258 \family default
2259 and
2259 and
2260 \family typewriter
2260 \family typewriter
2261 %ds
2261 %ds
2262 \family default
2262 \family default
2263 ) and via direct
2263 ) and via direct
2264 \family typewriter
2264 \family typewriter
2265 %cd
2265 %cd
2266 \family default
2266 \family default
2267 .
2267 .
2268 The latter keeps a history of visited directories and allows you to go
2268 The latter keeps a history of visited directories and allows you to go
2269 to any previously visited one.
2269 to any previously visited one.
2270 \layout Itemize
2270 \layout Itemize
2271
2271
2272 Use Python to manipulate the results of system commands.
2272 Use Python to manipulate the results of system commands.
2273 The `
2273 The `
2274 \family typewriter
2274 \family typewriter
2275 !!
2275 !!
2276 \family default
2276 \family default
2277 ' special syntax, and the
2277 ' special syntax, and the
2278 \family typewriter
2278 \family typewriter
2279 %sc
2279 %sc
2280 \family default
2280 \family default
2281 and
2281 and
2282 \family typewriter
2282 \family typewriter
2283 %sx
2283 %sx
2284 \family default
2284 \family default
2285 magic commands allow you to capture system output into Python variables.
2285 magic commands allow you to capture system output into Python variables.
2286 \layout Itemize
2286 \layout Itemize
2287
2287
2288 Expand python variables when calling the shell (either via
2288 Expand python variables when calling the shell (either via
2289 \family typewriter
2289 \family typewriter
2290 `!'
2290 `!'
2291 \family default
2291 \family default
2292 and
2292 and
2293 \family typewriter
2293 \family typewriter
2294 `!!'
2294 `!!'
2295 \family default
2295 \family default
2296 or via aliases) by prepending a
2296 or via aliases) by prepending a
2297 \family typewriter
2297 \family typewriter
2298 $
2298 $
2299 \family default
2299 \family default
2300 in front of them.
2300 in front of them.
2301 You can also expand complete python expressions.
2301 You can also expand complete python expressions.
2302 See sec.\SpecialChar ~
2302 See sec.\SpecialChar ~
2303
2303
2304 \begin_inset LatexCommand \ref{sub:System-shell-access}
2304 \begin_inset LatexCommand \ref{sub:System-shell-access}
2305
2305
2306 \end_inset
2306 \end_inset
2307
2307
2308 for more.
2308 for more.
2309 \layout Itemize
2309 \layout Itemize
2310
2310
2311 Use profiles to maintain different configurations (modules to load, function
2311 Use profiles to maintain different configurations (modules to load, function
2312 definitions, option settings) for particular tasks.
2312 definitions, option settings) for particular tasks.
2313 You can then have customized versions of IPython for specific purposes.
2313 You can then have customized versions of IPython for specific purposes.
2314 See sec.\SpecialChar ~
2314 See sec.\SpecialChar ~
2315
2315
2316 \begin_inset LatexCommand \ref{sec:profiles}
2316 \begin_inset LatexCommand \ref{sec:profiles}
2317
2317
2318 \end_inset
2318 \end_inset
2319
2319
2320 for more.
2320 for more.
2321 \layout Itemize
2321 \layout Itemize
2322
2322
2323 Embed IPython in your programs.
2323 Embed IPython in your programs.
2324 A few lines of code are enough to load a complete IPython inside your own
2324 A few lines of code are enough to load a complete IPython inside your own
2325 programs, giving you the ability to work with your data interactively after
2325 programs, giving you the ability to work with your data interactively after
2326 automatic processing has been completed.
2326 automatic processing has been completed.
2327 See sec.\SpecialChar ~
2327 See sec.\SpecialChar ~
2328
2328
2329 \begin_inset LatexCommand \ref{sec:embed}
2329 \begin_inset LatexCommand \ref{sec:embed}
2330
2330
2331 \end_inset
2331 \end_inset
2332
2332
2333 for more.
2333 for more.
2334 \layout Itemize
2334 \layout Itemize
2335
2335
2336 Use the Python profiler.
2336 Use the Python profiler.
2337 When dealing with performance issues, the
2337 When dealing with performance issues, the
2338 \family typewriter
2338 \family typewriter
2339 %run
2339 %run
2340 \family default
2340 \family default
2341 command with a
2341 command with a
2342 \family typewriter
2342 \family typewriter
2343 -p
2343 -p
2344 \family default
2344 \family default
2345 option allows you to run complete programs under the control of the Python
2345 option allows you to run complete programs under the control of the Python
2346 profiler.
2346 profiler.
2347 The
2347 The
2348 \family typewriter
2348 \family typewriter
2349 %prun
2349 %prun
2350 \family default
2350 \family default
2351 command does a similar job for single Python expressions (like function
2351 command does a similar job for single Python expressions (like function
2352 calls).
2352 calls).
2353 \layout Itemize
2353 \layout Itemize
2354
2354
2355 Use
2355 Use
2356 \family typewriter
2356 \family typewriter
2357 %edit
2357 %edit
2358 \family default
2358 \family default
2359 to have almost multiline editing.
2359 to have almost multiline editing.
2360 While IPython doesn't support true multiline editing, this command allows
2360 While IPython doesn't support true multiline editing, this command allows
2361 you to call an editor on the spot, and IPython will execute the code you
2361 you to call an editor on the spot, and IPython will execute the code you
2362 type in there as if it were typed interactively.
2362 type in there as if it were typed interactively.
2363 \layout Itemize
2363 \layout Itemize
2364
2364
2365 Use the IPython.demo.Demo class to load any Python script as an interactive
2365 Use the IPython.demo.Demo class to load any Python script as an interactive
2366 demo.
2366 demo.
2367 With a minimal amount of simple markup, you can control the execution of
2367 With a minimal amount of simple markup, you can control the execution of
2368 the script, stopping as needed.
2368 the script, stopping as needed.
2369 See sec.\SpecialChar ~
2369 See sec.\SpecialChar ~
2370
2370
2371 \begin_inset LatexCommand \ref{sec:interactive-demos}
2371 \begin_inset LatexCommand \ref{sec:interactive-demos}
2372
2372
2373 \end_inset
2373 \end_inset
2374
2374
2375 for more.
2375 for more.
2376 \layout Standard
2376 \layout Standard
2377
2377
2378 If you have your own favorite tip on using IPython efficiently for a certain
2378 If you have your own favorite tip on using IPython efficiently for a certain
2379 task (especially things which can't be done in the normal Python interpreter),
2379 task (especially things which can't be done in the normal Python interpreter),
2380 don't hesitate to send it!
2380 don't hesitate to send it!
2381 \layout Section
2381 \layout Section
2382
2382
2383 Command-line use
2383 Command-line use
2384 \layout Standard
2384 \layout Standard
2385
2385
2386 You start IPython with the command:
2386 You start IPython with the command:
2387 \layout Standard
2387 \layout Standard
2388
2388
2389
2389
2390 \family typewriter
2390 \family typewriter
2391 $ ipython [options] files
2391 $ ipython [options] files
2392 \layout Standard
2392 \layout Standard
2393
2393
2394 If invoked with no options, it executes all the files listed in sequence
2394 If invoked with no options, it executes all the files listed in sequence
2395 and drops you into the interpreter while still acknowledging any options
2395 and drops you into the interpreter while still acknowledging any options
2396 you may have set in your ipythonrc file.
2396 you may have set in your ipythonrc file.
2397 This behavior is different from standard Python, which when called as
2397 This behavior is different from standard Python, which when called as
2398 \family typewriter
2398 \family typewriter
2399 python -i
2399 python -i
2400 \family default
2400 \family default
2401 will only execute one file and ignore your configuration setup.
2401 will only execute one file and ignore your configuration setup.
2402 \layout Standard
2402 \layout Standard
2403
2403
2404 Please note that some of the configuration options are not available at
2404 Please note that some of the configuration options are not available at
2405 the command line, simply because they are not practical here.
2405 the command line, simply because they are not practical here.
2406 Look into your ipythonrc configuration file for details on those.
2406 Look into your ipythonrc configuration file for details on those.
2407 This file typically installed in the
2407 This file typically installed in the
2408 \family typewriter
2408 \family typewriter
2409 $HOME/.ipython
2409 $HOME/.ipython
2410 \family default
2410 \family default
2411 directory.
2411 directory.
2412 For Windows users,
2412 For Windows users,
2413 \family typewriter
2413 \family typewriter
2414 $HOME
2414 $HOME
2415 \family default
2415 \family default
2416 resolves to
2416 resolves to
2417 \family typewriter
2417 \family typewriter
2418 C:
2418 C:
2419 \backslash
2419 \backslash
2420
2420
2421 \backslash
2421 \backslash
2422 Documents and Settings
2422 Documents and Settings
2423 \backslash
2423 \backslash
2424
2424
2425 \backslash
2425 \backslash
2426 YourUserName
2426 YourUserName
2427 \family default
2427 \family default
2428 in most instances.
2428 in most instances.
2429 In the rest of this text, we will refer to this directory as
2429 In the rest of this text, we will refer to this directory as
2430 \family typewriter
2430 \family typewriter
2431 IPYTHONDIR
2431 IPYTHONDIR
2432 \family default
2432 \family default
2433 .
2433 .
2434 \layout Subsection
2434 \layout Subsection
2435
2435
2436
2436
2437 \begin_inset LatexCommand \label{sec:threading-opts}
2437 \begin_inset LatexCommand \label{sec:threading-opts}
2438
2438
2439 \end_inset
2439 \end_inset
2440
2440
2441 Special Threading Options
2441 Special Threading Options
2442 \layout Standard
2442 \layout Standard
2443
2443
2444 The following special options are ONLY valid at the beginning of the command
2444 The following special options are ONLY valid at the beginning of the command
2445 line, and not later.
2445 line, and not later.
2446 This is because they control the initial- ization of ipython itself, before
2446 This is because they control the initial- ization of ipython itself, before
2447 the normal option-handling mechanism is active.
2447 the normal option-handling mechanism is active.
2448 \layout List
2448 \layout List
2449 \labelwidthstring 00.00.0000
2449 \labelwidthstring 00.00.0000
2450
2450
2451
2451
2452 \family typewriter
2452 \family typewriter
2453 \series bold
2453 \series bold
2454 -gthread,\SpecialChar ~
2454 -gthread,\SpecialChar ~
2455 -qthread,\SpecialChar ~
2455 -qthread,\SpecialChar ~
2456 -wthread,\SpecialChar ~
2456 -wthread,\SpecialChar ~
2457 -pylab:
2457 -pylab:
2458 \family default
2458 \family default
2459 \series default
2459 \series default
2460 Only
2460 Only
2461 \emph on
2461 \emph on
2462 one
2462 one
2463 \emph default
2463 \emph default
2464 of these can be given, and it can only be given as the first option passed
2464 of these can be given, and it can only be given as the first option passed
2465 to IPython (it will have no effect in any other position).
2465 to IPython (it will have no effect in any other position).
2466 They provide threading support for the GTK Qt and WXPython toolkits, and
2466 They provide threading support for the GTK Qt and WXPython toolkits, and
2467 for the matplotlib library.
2467 for the matplotlib library.
2468 \layout List
2468 \layout List
2469 \labelwidthstring 00.00.0000
2469 \labelwidthstring 00.00.0000
2470
2470
2471 \SpecialChar ~
2471 \SpecialChar ~
2472 With any of the first three options, IPython starts running a separate
2472 With any of the first three options, IPython starts running a separate
2473 thread for the graphical toolkit's operation, so that you can open and
2473 thread for the graphical toolkit's operation, so that you can open and
2474 control graphical elements from within an IPython command line, without
2474 control graphical elements from within an IPython command line, without
2475 blocking.
2475 blocking.
2476 All three provide essentially the same functionality, respectively for
2476 All three provide essentially the same functionality, respectively for
2477 GTK, QT and WXWidgets (via their Python interfaces).
2477 GTK, QT and WXWidgets (via their Python interfaces).
2478 \layout List
2478 \layout List
2479 \labelwidthstring 00.00.0000
2479 \labelwidthstring 00.00.0000
2480
2480
2481 \SpecialChar ~
2481 \SpecialChar ~
2482 If
2482 If
2483 \family typewriter
2483 \family typewriter
2484 -pylab
2484 -pylab
2485 \family default
2485 \family default
2486 is given, IPython loads special support for the mat plotlib library (
2486 is given, IPython loads special support for the mat plotlib library (
2487 \begin_inset LatexCommand \htmlurl{http://matplotlib.sourceforge.net}
2487 \begin_inset LatexCommand \htmlurl{http://matplotlib.sourceforge.net}
2488
2488
2489 \end_inset
2489 \end_inset
2490
2490
2491 ), allowing interactive usage of any of its backends as defined in the user's
2491 ), allowing interactive usage of any of its backends as defined in the user's
2492
2492
2493 \family typewriter
2493 \family typewriter
2494 ~/.matplotlib/matplotlibrc
2494 ~/.matplotlib/matplotlibrc
2495 \family default
2495 \family default
2496 file.
2496 file.
2497 It automatically activates GTK, Qt or WX threading for IPyhton if the choice
2497 It automatically activates GTK, Qt or WX threading for IPyhton if the choice
2498 of matplotlib backend requires it.
2498 of matplotlib backend requires it.
2499 It also modifies the
2499 It also modifies the
2500 \family typewriter
2500 \family typewriter
2501 %run
2501 %run
2502 \family default
2502 \family default
2503 command to correctly execute (without blocking) any matplotlib-based script
2503 command to correctly execute (without blocking) any matplotlib-based script
2504 which calls
2504 which calls
2505 \family typewriter
2505 \family typewriter
2506 show()
2506 show()
2507 \family default
2507 \family default
2508 at the end.
2508 at the end.
2509
2509
2510 \layout List
2510 \layout List
2511 \labelwidthstring 00.00.0000
2511 \labelwidthstring 00.00.0000
2512
2512
2513
2513
2514 \family typewriter
2514 \family typewriter
2515 \series bold
2515 \series bold
2516 -tk
2516 -tk
2517 \family default
2517 \family default
2518 \series default
2518 \series default
2519 The
2519 The
2520 \family typewriter
2520 \family typewriter
2521 -g/q/wthread
2521 -g/q/wthread
2522 \family default
2522 \family default
2523 options, and
2523 options, and
2524 \family typewriter
2524 \family typewriter
2525 -pylab
2525 -pylab
2526 \family default
2526 \family default
2527 (if matplotlib is configured to use GTK, Qt or WX), will normally block
2527 (if matplotlib is configured to use GTK, Qt or WX), will normally block
2528 Tk graphical interfaces.
2528 Tk graphical interfaces.
2529 This means that when either GTK, Qt or WX threading is active, any attempt
2529 This means that when either GTK, Qt or WX threading is active, any attempt
2530 to open a Tk GUI will result in a dead window, and possibly cause the Python
2530 to open a Tk GUI will result in a dead window, and possibly cause the Python
2531 interpreter to crash.
2531 interpreter to crash.
2532 An extra option,
2532 An extra option,
2533 \family typewriter
2533 \family typewriter
2534 -tk
2534 -tk
2535 \family default
2535 \family default
2536 , is available to address this issue.
2536 , is available to address this issue.
2537 It can
2537 It can
2538 \emph on
2538 \emph on
2539 only
2539 only
2540 \emph default
2540 \emph default
2541 be given as a
2541 be given as a
2542 \emph on
2542 \emph on
2543 second
2543 second
2544 \emph default
2544 \emph default
2545 option after any of the above (
2545 option after any of the above (
2546 \family typewriter
2546 \family typewriter
2547 -gthread
2547 -gthread
2548 \family default
2548 \family default
2549 ,
2549 ,
2550 \family typewriter
2550 \family typewriter
2551 -wthread
2551 -wthread
2552 \family default
2552 \family default
2553 or
2553 or
2554 \family typewriter
2554 \family typewriter
2555 -pylab
2555 -pylab
2556 \family default
2556 \family default
2557 ).
2557 ).
2558 \layout List
2558 \layout List
2559 \labelwidthstring 00.00.0000
2559 \labelwidthstring 00.00.0000
2560
2560
2561 \SpecialChar ~
2561 \SpecialChar ~
2562 If
2562 If
2563 \family typewriter
2563 \family typewriter
2564 -tk
2564 -tk
2565 \family default
2565 \family default
2566 is given, IPython will try to coordinate Tk threading with GTK, Qt or WX.
2566 is given, IPython will try to coordinate Tk threading with GTK, Qt or WX.
2567 This is however potentially unreliable, and you will have to test on your
2567 This is however potentially unreliable, and you will have to test on your
2568 platform and Python configuration to determine whether it works for you.
2568 platform and Python configuration to determine whether it works for you.
2569 Debian users have reported success, apparently due to the fact that Debian
2569 Debian users have reported success, apparently due to the fact that Debian
2570 builds all of Tcl, Tk, Tkinter and Python with pthreads support.
2570 builds all of Tcl, Tk, Tkinter and Python with pthreads support.
2571 Under other Linux environments (such as Fedora Core 2/3), this option has
2571 Under other Linux environments (such as Fedora Core 2/3), this option has
2572 caused random crashes and lockups of the Python interpreter.
2572 caused random crashes and lockups of the Python interpreter.
2573 Under other operating systems (Mac OSX and Windows), you'll need to try
2573 Under other operating systems (Mac OSX and Windows), you'll need to try
2574 it to find out, since currently no user reports are available.
2574 it to find out, since currently no user reports are available.
2575 \layout List
2575 \layout List
2576 \labelwidthstring 00.00.0000
2576 \labelwidthstring 00.00.0000
2577
2577
2578 \SpecialChar ~
2578 \SpecialChar ~
2579 There is unfortunately no way for IPython to determine at run time whether
2579 There is unfortunately no way for IPython to determine at run time whether
2580
2580
2581 \family typewriter
2581 \family typewriter
2582 -tk
2582 -tk
2583 \family default
2583 \family default
2584 will work reliably or not, so you will need to do some experiments before
2584 will work reliably or not, so you will need to do some experiments before
2585 relying on it for regular work.
2585 relying on it for regular work.
2586
2586
2587 \layout Subsection
2587 \layout Subsection
2588
2588
2589
2589
2590 \begin_inset LatexCommand \label{sec:cmd-line-opts}
2590 \begin_inset LatexCommand \label{sec:cmd-line-opts}
2591
2591
2592 \end_inset
2592 \end_inset
2593
2593
2594 Regular Options
2594 Regular Options
2595 \layout Standard
2595 \layout Standard
2596
2596
2597 After the above threading options have been given, regular options can follow
2597 After the above threading options have been given, regular options can follow
2598 in any order.
2598 in any order.
2599 All options can be abbreviated to their shortest non-ambiguous form and
2599 All options can be abbreviated to their shortest non-ambiguous form and
2600 are case-sensitive.
2600 are case-sensitive.
2601 One or two dashes can be used.
2601 One or two dashes can be used.
2602 Some options have an alternate short form, indicated after a
2602 Some options have an alternate short form, indicated after a
2603 \family typewriter
2603 \family typewriter
2604 |
2604 |
2605 \family default
2605 \family default
2606 .
2606 .
2607 \layout Standard
2607 \layout Standard
2608
2608
2609 Most options can also be set from your ipythonrc configuration file.
2609 Most options can also be set from your ipythonrc configuration file.
2610 See the provided example for more details on what the options do.
2610 See the provided example for more details on what the options do.
2611 Options given at the command line override the values set in the ipythonrc
2611 Options given at the command line override the values set in the ipythonrc
2612 file.
2612 file.
2613 \layout Standard
2613 \layout Standard
2614
2614
2615 All options with a
2615 All options with a
2616 \family typewriter
2616 \family typewriter
2617 no|
2617 [no]
2618 \family default
2618 \family default
2619 prepended can be specified in 'no' form (
2619 prepended can be specified in negated form (
2620 \family typewriter
2620 \family typewriter
2621 -nooption
2621 -nooption
2622 \family default
2622 \family default
2623 instead of
2623 instead of
2624 \family typewriter
2624 \family typewriter
2625 -option
2625 -option
2626 \family default
2626 \family default
2627 ) to turn the feature off.
2627 ) to turn the feature off.
2628 \layout List
2628 \layout List
2629 \labelwidthstring 00.00.0000
2629 \labelwidthstring 00.00.0000
2630
2630
2631
2631
2632 \family typewriter
2632 \family typewriter
2633 \series bold
2633 \series bold
2634 -help
2634 -help
2635 \family default
2635 \family default
2636 \series default
2636 \series default
2637 : print a help message and exit.
2637 : print a help message and exit.
2638 \layout List
2638 \layout List
2639 \labelwidthstring 00.00.0000
2639 \labelwidthstring 00.00.0000
2640
2640
2641
2641
2642 \family typewriter
2642 \family typewriter
2643 \series bold
2643 \series bold
2644 -pylab:
2644 -pylab:
2645 \family default
2645 \family default
2646 \series default
2646 \series default
2647 this can
2647 this can
2648 \emph on
2648 \emph on
2649 only
2649 only
2650 \emph default
2650 \emph default
2651 be given as the
2651 be given as the
2652 \emph on
2652 \emph on
2653 first
2653 first
2654 \emph default
2654 \emph default
2655 option passed to IPython (it will have no effect in any other position).
2655 option passed to IPython (it will have no effect in any other position).
2656 It adds special support for the matplotlib library (
2656 It adds special support for the matplotlib library (
2657 \begin_inset LatexCommand \htmlurl[http://matplotlib.sourceforge.net]{http://matplotlib.sourceforge.net}
2657 \begin_inset LatexCommand \htmlurl[http://matplotlib.sourceforge.net]{http://matplotlib.sourceforge.net}
2658
2658
2659 \end_inset
2659 \end_inset
2660
2660
2661 ), allowing interactive usage of any of its backends as defined in the user's
2661 ), allowing interactive usage of any of its backends as defined in the user's
2662
2662
2663 \family typewriter
2663 \family typewriter
2664 .matplotlibrc
2664 .matplotlibrc
2665 \family default
2665 \family default
2666 file.
2666 file.
2667 It automatically activates GTK or WX threading for IPyhton if the choice
2667 It automatically activates GTK or WX threading for IPyhton if the choice
2668 of matplotlib backend requires it.
2668 of matplotlib backend requires it.
2669 It also modifies the
2669 It also modifies the
2670 \family typewriter
2670 \family typewriter
2671 %run
2671 %run
2672 \family default
2672 \family default
2673 command to correctly execute (without blocking) any matplotlib-based script
2673 command to correctly execute (without blocking) any matplotlib-based script
2674 which calls
2674 which calls
2675 \family typewriter
2675 \family typewriter
2676 show()
2676 show()
2677 \family default
2677 \family default
2678 at the end.
2678 at the end.
2679 See Sec.\SpecialChar ~
2679 See Sec.\SpecialChar ~
2680
2680
2681 \begin_inset LatexCommand \ref{sec:matplotlib-support}
2681 \begin_inset LatexCommand \ref{sec:matplotlib-support}
2682
2682
2683 \end_inset
2683 \end_inset
2684
2684
2685 for more details.
2685 for more details.
2686 \layout List
2686 \layout List
2687 \labelwidthstring 00.00.0000
2687 \labelwidthstring 00.00.0000
2688
2688
2689
2689
2690 \family typewriter
2690 \family typewriter
2691 \series bold
2691 \series bold
2692 -no|automagic
2692 -[no]automagic
2693 \series default
2693 \series default
2694 :
2694 :
2695 \family default
2695 \family default
2696 make magic commands automatic (without needing their first character to
2696 make magic commands automatic (without needing their first character to
2697 be
2697 be
2698 \family typewriter
2698 \family typewriter
2699 %
2699 %
2700 \family default
2700 \family default
2701 ).
2701 ).
2702 Type
2702 Type
2703 \family typewriter
2703 \family typewriter
2704 %magic
2704 %magic
2705 \family default
2705 \family default
2706 at the IPython prompt for more information.
2706 at the IPython prompt for more information.
2707 \layout List
2707 \layout List
2708 \labelwidthstring 00.00.0000
2708 \labelwidthstring 00.00.0000
2709
2709
2710
2710
2711 \family typewriter
2711 \family typewriter
2712 \series bold
2712 \series bold
2713 -no|banner
2713 -[no]banner
2714 \series default
2714 \series default
2715 :
2715 :
2716 \family default
2716 \family default
2717 Print the initial information banner (default on).
2717 Print the initial information banner (default on).
2718 \layout List
2718 \layout List
2719 \labelwidthstring 00.00.0000
2719 \labelwidthstring 00.00.0000
2720
2720
2721
2721
2722 \family typewriter
2722 \family typewriter
2723 \series bold
2723 \series bold
2724 -c\SpecialChar ~
2724 -c\SpecialChar ~
2725 <command>:
2725 <command>:
2726 \family default
2726 \family default
2727 \series default
2727 \series default
2728 execute the given command string, and set sys.argv to
2728 execute the given command string, and set sys.argv to
2729 \family typewriter
2729 \family typewriter
2730 ['c']
2730 ['c']
2731 \family default
2731 \family default
2732 .
2732 .
2733 This is similar to the
2733 This is similar to the
2734 \family typewriter
2734 \family typewriter
2735 -c
2735 -c
2736 \family default
2736 \family default
2737 option in the normal Python interpreter.
2737 option in the normal Python interpreter.
2738
2738
2739 \layout List
2739 \layout List
2740 \labelwidthstring 00.00.0000
2740 \labelwidthstring 00.00.0000
2741
2741
2742
2742
2743 \family typewriter
2743 \family typewriter
2744 \series bold
2744 \series bold
2745 -cache_size|cs\SpecialChar ~
2745 -cache_size|cs\SpecialChar ~
2746 <n>
2746 <n>
2747 \series default
2747 \series default
2748 :
2748 :
2749 \family default
2749 \family default
2750 size of the output cache (maximum number of entries to hold in memory).
2750 size of the output cache (maximum number of entries to hold in memory).
2751 The default is 1000, you can change it permanently in your config file.
2751 The default is 1000, you can change it permanently in your config file.
2752 Setting it to 0 completely disables the caching system, and the minimum
2752 Setting it to 0 completely disables the caching system, and the minimum
2753 value accepted is 20 (if you provide a value less than 20, it is reset
2753 value accepted is 20 (if you provide a value less than 20, it is reset
2754 to 0 and a warning is issued) This limit is defined because otherwise you'll
2754 to 0 and a warning is issued) This limit is defined because otherwise you'll
2755 spend more time re-flushing a too small cache than working.
2755 spend more time re-flushing a too small cache than working.
2756 \layout List
2756 \layout List
2757 \labelwidthstring 00.00.0000
2757 \labelwidthstring 00.00.0000
2758
2758
2759
2759
2760 \family typewriter
2760 \family typewriter
2761 \series bold
2761 \series bold
2762 -classic|cl
2762 -classic|cl
2763 \series default
2763 \series default
2764 :
2764 :
2765 \family default
2765 \family default
2766 Gives IPython a similar feel to the classic Python prompt.
2766 Gives IPython a similar feel to the classic Python prompt.
2767 \layout List
2767 \layout List
2768 \labelwidthstring 00.00.0000
2768 \labelwidthstring 00.00.0000
2769
2769
2770
2770
2771 \family typewriter
2771 \family typewriter
2772 \series bold
2772 \series bold
2773 -colors\SpecialChar ~
2773 -colors\SpecialChar ~
2774 <scheme>:
2774 <scheme>:
2775 \family default
2775 \family default
2776 \series default
2776 \series default
2777 Color scheme for prompts and exception reporting.
2777 Color scheme for prompts and exception reporting.
2778 Currently implemented: NoColor, Linux and LightBG.
2778 Currently implemented: NoColor, Linux and LightBG.
2779 \layout List
2779 \layout List
2780 \labelwidthstring 00.00.0000
2780 \labelwidthstring 00.00.0000
2781
2781
2782
2782
2783 \family typewriter
2783 \family typewriter
2784 \series bold
2784 \series bold
2785 -no|color_info:
2785 -[no]color_info:
2786 \family default
2786 \family default
2787 \series default
2787 \series default
2788 IPython can display information about objects via a set of functions, and
2788 IPython can display information about objects via a set of functions, and
2789 optionally can use colors for this, syntax highlighting source code and
2789 optionally can use colors for this, syntax highlighting source code and
2790 various other elements.
2790 various other elements.
2791 However, because this information is passed through a pager (like 'less')
2791 However, because this information is passed through a pager (like 'less')
2792 and many pagers get confused with color codes, this option is off by default.
2792 and many pagers get confused with color codes, this option is off by default.
2793 You can test it and turn it on permanently in your ipythonrc file if it
2793 You can test it and turn it on permanently in your ipythonrc file if it
2794 works for you.
2794 works for you.
2795 As a reference, the 'less' pager supplied with Mandrake 8.2 works ok, but
2795 As a reference, the 'less' pager supplied with Mandrake 8.2 works ok, but
2796 that in RedHat 7.2 doesn't.
2796 that in RedHat 7.2 doesn't.
2797 \layout List
2797 \layout List
2798 \labelwidthstring 00.00.0000
2798 \labelwidthstring 00.00.0000
2799
2799
2800 \SpecialChar ~
2800 \SpecialChar ~
2801 Test it and turn it on permanently if it works with your system.
2801 Test it and turn it on permanently if it works with your system.
2802 The magic function
2802 The magic function
2803 \family typewriter
2803 \family typewriter
2804 %color_info
2804 %color_info
2805 \family default
2805 \family default
2806 allows you to toggle this interactively for testing.
2806 allows you to toggle this interactively for testing.
2807 \layout List
2807 \layout List
2808 \labelwidthstring 00.00.0000
2808 \labelwidthstring 00.00.0000
2809
2809
2810
2810
2811 \family typewriter
2811 \family typewriter
2812 \series bold
2812 \series bold
2813 -no|debug
2813 -[no]debug
2814 \family default
2814 \family default
2815 \series default
2815 \series default
2816 : Show information about the loading process.
2816 : Show information about the loading process.
2817 Very useful to pin down problems with your configuration files or to get
2817 Very useful to pin down problems with your configuration files or to get
2818 details about session restores.
2818 details about session restores.
2819 \layout List
2819 \layout List
2820 \labelwidthstring 00.00.0000
2820 \labelwidthstring 00.00.0000
2821
2821
2822
2822
2823 \family typewriter
2823 \family typewriter
2824 \series bold
2824 \series bold
2825 -no|deep_reload
2825 -[no]deep_reload
2826 \series default
2826 \series default
2827 :
2827 :
2828 \family default
2828 \family default
2829 IPython can use the
2829 IPython can use the
2830 \family typewriter
2830 \family typewriter
2831 deep_reload
2831 deep_reload
2832 \family default
2832 \family default
2833 module which reloads changes in modules recursively (it replaces the
2833 module which reloads changes in modules recursively (it replaces the
2834 \family typewriter
2834 \family typewriter
2835 reload()
2835 reload()
2836 \family default
2836 \family default
2837 function, so you don't need to change anything to use it).
2837 function, so you don't need to change anything to use it).
2838
2838
2839 \family typewriter
2839 \family typewriter
2840 deep_reload()
2840 deep_reload()
2841 \family default
2841 \family default
2842 forces a full reload of modules whose code may have changed, which the
2842 forces a full reload of modules whose code may have changed, which the
2843 default
2843 default
2844 \family typewriter
2844 \family typewriter
2845 reload()
2845 reload()
2846 \family default
2846 \family default
2847 function does not.
2847 function does not.
2848 \layout List
2848 \layout List
2849 \labelwidthstring 00.00.0000
2849 \labelwidthstring 00.00.0000
2850
2850
2851 \SpecialChar ~
2851 \SpecialChar ~
2852 When deep_reload is off, IPython will use the normal
2852 When deep_reload is off, IPython will use the normal
2853 \family typewriter
2853 \family typewriter
2854 reload()
2854 reload()
2855 \family default
2855 \family default
2856 , but deep_reload will still be available as
2856 , but deep_reload will still be available as
2857 \family typewriter
2857 \family typewriter
2858 dreload()
2858 dreload()
2859 \family default
2859 \family default
2860 .
2860 .
2861 This feature is off by default [which means that you have both normal
2861 This feature is off by default [which means that you have both normal
2862 \family typewriter
2862 \family typewriter
2863 reload()
2863 reload()
2864 \family default
2864 \family default
2865 and
2865 and
2866 \family typewriter
2866 \family typewriter
2867 dreload()
2867 dreload()
2868 \family default
2868 \family default
2869 ].
2869 ].
2870 \layout List
2870 \layout List
2871 \labelwidthstring 00.00.0000
2871 \labelwidthstring 00.00.0000
2872
2872
2873
2873
2874 \family typewriter
2874 \family typewriter
2875 \series bold
2875 \series bold
2876 -editor\SpecialChar ~
2876 -editor\SpecialChar ~
2877 <name>
2877 <name>
2878 \family default
2878 \family default
2879 \series default
2879 \series default
2880 : Which editor to use with the
2880 : Which editor to use with the
2881 \family typewriter
2881 \family typewriter
2882 %edit
2882 %edit
2883 \family default
2883 \family default
2884 command.
2884 command.
2885 By default, IPython will honor your
2885 By default, IPython will honor your
2886 \family typewriter
2886 \family typewriter
2887 EDITOR
2887 EDITOR
2888 \family default
2888 \family default
2889 environment variable (if not set, vi is the Unix default and notepad the
2889 environment variable (if not set, vi is the Unix default and notepad the
2890 Windows one).
2890 Windows one).
2891 Since this editor is invoked on the fly by IPython and is meant for editing
2891 Since this editor is invoked on the fly by IPython and is meant for editing
2892 small code snippets, you may want to use a small, lightweight editor here
2892 small code snippets, you may want to use a small, lightweight editor here
2893 (in case your default
2893 (in case your default
2894 \family typewriter
2894 \family typewriter
2895 EDITOR
2895 EDITOR
2896 \family default
2896 \family default
2897 is something like Emacs).
2897 is something like Emacs).
2898 \layout List
2898 \layout List
2899 \labelwidthstring 00.00.0000
2899 \labelwidthstring 00.00.0000
2900
2900
2901
2901
2902 \family typewriter
2902 \family typewriter
2903 \series bold
2903 \series bold
2904 -ipythondir\SpecialChar ~
2904 -ipythondir\SpecialChar ~
2905 <name>
2905 <name>
2906 \series default
2906 \series default
2907 :
2907 :
2908 \family default
2908 \family default
2909 name of your IPython configuration directory
2909 name of your IPython configuration directory
2910 \family typewriter
2910 \family typewriter
2911 IPYTHONDIR
2911 IPYTHONDIR
2912 \family default
2912 \family default
2913 .
2913 .
2914 This can also be specified through the environment variable
2914 This can also be specified through the environment variable
2915 \family typewriter
2915 \family typewriter
2916 IPYTHONDIR
2916 IPYTHONDIR
2917 \family default
2917 \family default
2918 .
2918 .
2919 \layout List
2919 \layout List
2920 \labelwidthstring 00.00.0000
2920 \labelwidthstring 00.00.0000
2921
2921
2922
2922
2923 \family typewriter
2923 \family typewriter
2924 \series bold
2924 \series bold
2925 -log|l
2925 -log|l
2926 \family default
2926 \family default
2927 \series default
2927 \series default
2928 : generate a log file of all input.
2928 : generate a log file of all input.
2929 Defaults to
2929 Defaults to
2930 \family typewriter
2930 \family typewriter
2931 $IPYTHONDIR/log
2931 $IPYTHONDIR/log
2932 \family default
2932 \family default
2933 .
2933 .
2934 You can use this to later restore a session by loading your logfile as
2934 You can use this to later restore a session by loading your logfile as
2935 a file to be executed with option
2935 a file to be executed with option
2936 \family typewriter
2936 \family typewriter
2937 -logplay
2937 -logplay
2938 \family default
2938 \family default
2939 (see below).
2939 (see below).
2940 \layout List
2940 \layout List
2941 \labelwidthstring 00.00.0000
2941 \labelwidthstring 00.00.0000
2942
2942
2943
2943
2944 \family typewriter
2944 \family typewriter
2945 \series bold
2945 \series bold
2946 -logfile|lf\SpecialChar ~
2946 -logfile|lf\SpecialChar ~
2947 <name>
2947 <name>
2948 \series default
2948 \series default
2949 :
2949 :
2950 \family default
2950 \family default
2951 specify the name of your logfile.
2951 specify the name of your logfile.
2952 \layout List
2952 \layout List
2953 \labelwidthstring 00.00.0000
2953 \labelwidthstring 00.00.0000
2954
2954
2955
2955
2956 \family typewriter
2956 \family typewriter
2957 \series bold
2957 \series bold
2958 -logplay|lp\SpecialChar ~
2958 -logplay|lp\SpecialChar ~
2959 <name>
2959 <name>
2960 \series default
2960 \series default
2961 :
2961 :
2962 \family default
2962 \family default
2963 you can replay a previous log.
2963 you can replay a previous log.
2964 For restoring a session as close as possible to the state you left it in,
2964 For restoring a session as close as possible to the state you left it in,
2965 use this option (don't just run the logfile).
2965 use this option (don't just run the logfile).
2966 With
2966 With
2967 \family typewriter
2967 \family typewriter
2968 -logplay
2968 -logplay
2969 \family default
2969 \family default
2970 , IPython will try to reconstruct the previous working environment in full,
2970 , IPython will try to reconstruct the previous working environment in full,
2971 not just execute the commands in the logfile.
2971 not just execute the commands in the logfile.
2972 \layout List
2972 \layout List
2973 \labelwidthstring 00.00.0000
2973 \labelwidthstring 00.00.0000
2974
2974
2975 \SpecialChar ~
2975 \SpecialChar ~
2976 When a session is restored, logging is automatically turned on again with
2976 When a session is restored, logging is automatically turned on again with
2977 the name of the logfile it was invoked with (it is read from the log header).
2977 the name of the logfile it was invoked with (it is read from the log header).
2978 So once you've turned logging on for a session, you can quit IPython and
2978 So once you've turned logging on for a session, you can quit IPython and
2979 reload it as many times as you want and it will continue to log its history
2979 reload it as many times as you want and it will continue to log its history
2980 and restore from the beginning every time.
2980 and restore from the beginning every time.
2981 \layout List
2981 \layout List
2982 \labelwidthstring 00.00.0000
2982 \labelwidthstring 00.00.0000
2983
2983
2984 \SpecialChar ~
2984 \SpecialChar ~
2985 Caveats: there are limitations in this option.
2985 Caveats: there are limitations in this option.
2986 The history variables
2986 The history variables
2987 \family typewriter
2987 \family typewriter
2988 _i*
2988 _i*
2989 \family default
2989 \family default
2990 ,
2990 ,
2991 \family typewriter
2991 \family typewriter
2992 _*
2992 _*
2993 \family default
2993 \family default
2994 and
2994 and
2995 \family typewriter
2995 \family typewriter
2996 _dh
2996 _dh
2997 \family default
2997 \family default
2998 don't get restored properly.
2998 don't get restored properly.
2999 In the future we will try to implement full session saving by writing and
2999 In the future we will try to implement full session saving by writing and
3000 retrieving a 'snapshot' of the memory state of IPython.
3000 retrieving a 'snapshot' of the memory state of IPython.
3001 But our first attempts failed because of inherent limitations of Python's
3001 But our first attempts failed because of inherent limitations of Python's
3002 Pickle module, so this may have to wait.
3002 Pickle module, so this may have to wait.
3003 \layout List
3003 \layout List
3004 \labelwidthstring 00.00.0000
3004 \labelwidthstring 00.00.0000
3005
3005
3006
3006
3007 \family typewriter
3007 \family typewriter
3008 \series bold
3008 \series bold
3009 -no|messages
3009 -[no]messages
3010 \series default
3010 \series default
3011 :
3011 :
3012 \family default
3012 \family default
3013 Print messages which IPython collects about its startup process (default
3013 Print messages which IPython collects about its startup process (default
3014 on).
3014 on).
3015 \layout List
3015 \layout List
3016 \labelwidthstring 00.00.0000
3016 \labelwidthstring 00.00.0000
3017
3017
3018
3018
3019 \family typewriter
3019 \family typewriter
3020 \series bold
3020 \series bold
3021 -no|pdb
3021 -[no]pdb
3022 \family default
3022 \family default
3023 \series default
3023 \series default
3024 : Automatically call the pdb debugger after every uncaught exception.
3024 : Automatically call the pdb debugger after every uncaught exception.
3025 If you are used to debugging using pdb, this puts you automatically inside
3025 If you are used to debugging using pdb, this puts you automatically inside
3026 of it after any call (either in IPython or in code called by it) which
3026 of it after any call (either in IPython or in code called by it) which
3027 triggers an exception which goes uncaught.
3027 triggers an exception which goes uncaught.
3028 \layout List
3028 \layout List
3029 \labelwidthstring 00.00.0000
3029 \labelwidthstring 00.00.0000
3030
3030
3031
3031
3032 \family typewriter
3032 \family typewriter
3033 \series bold
3033 \series bold
3034 -no|pprint
3034 -[no]pprint
3035 \series default
3035 \series default
3036 :
3036 :
3037 \family default
3037 \family default
3038 ipython can optionally use the pprint (pretty printer) module for displaying
3038 ipython can optionally use the pprint (pretty printer) module for displaying
3039 results.
3039 results.
3040 pprint tends to give a nicer display of nested data structures.
3040 pprint tends to give a nicer display of nested data structures.
3041 If you like it, you can turn it on permanently in your config file (default
3041 If you like it, you can turn it on permanently in your config file (default
3042 off).
3042 off).
3043 \layout List
3043 \layout List
3044 \labelwidthstring 00.00.0000
3044 \labelwidthstring 00.00.0000
3045
3045
3046
3046
3047 \family typewriter
3047 \family typewriter
3048 \series bold
3048 \series bold
3049 -profile|p <name>
3049 -profile|p <name>
3050 \series default
3050 \series default
3051 :
3051 :
3052 \family default
3052 \family default
3053 assume that your config file is
3053 assume that your config file is
3054 \family typewriter
3054 \family typewriter
3055 ipythonrc-<name>
3055 ipythonrc-<name>
3056 \family default
3056 \family default
3057 (looks in current dir first, then in
3057 (looks in current dir first, then in
3058 \family typewriter
3058 \family typewriter
3059 IPYTHONDIR
3059 IPYTHONDIR
3060 \family default
3060 \family default
3061 ).
3061 ).
3062 This is a quick way to keep and load multiple config files for different
3062 This is a quick way to keep and load multiple config files for different
3063 tasks, especially if you use the include option of config files.
3063 tasks, especially if you use the include option of config files.
3064 You can keep a basic
3064 You can keep a basic
3065 \family typewriter
3065 \family typewriter
3066 IPYTHONDIR/ipythonrc
3066 IPYTHONDIR/ipythonrc
3067 \family default
3067 \family default
3068 file and then have other 'profiles' which include this one and load extra
3068 file and then have other 'profiles' which include this one and load extra
3069 things for particular tasks.
3069 things for particular tasks.
3070 For example:
3070 For example:
3071 \layout List
3071 \layout List
3072 \labelwidthstring 00.00.0000
3072 \labelwidthstring 00.00.0000
3073
3073
3074
3074
3075 \family typewriter
3075 \family typewriter
3076 \SpecialChar ~
3076 \SpecialChar ~
3077
3077
3078 \family default
3078 \family default
3079 1.
3079 1.
3080
3080
3081 \family typewriter
3081 \family typewriter
3082 $HOME/.ipython/ipythonrc
3082 $HOME/.ipython/ipythonrc
3083 \family default
3083 \family default
3084 : load basic things you always want.
3084 : load basic things you always want.
3085 \layout List
3085 \layout List
3086 \labelwidthstring 00.00.0000
3086 \labelwidthstring 00.00.0000
3087
3087
3088
3088
3089 \family typewriter
3089 \family typewriter
3090 \SpecialChar ~
3090 \SpecialChar ~
3091
3091
3092 \family default
3092 \family default
3093 2.
3093 2.
3094
3094
3095 \family typewriter
3095 \family typewriter
3096 $HOME/.ipython/ipythonrc-math
3096 $HOME/.ipython/ipythonrc-math
3097 \family default
3097 \family default
3098 : load (1) and basic math-related modules.
3098 : load (1) and basic math-related modules.
3099
3099
3100 \layout List
3100 \layout List
3101 \labelwidthstring 00.00.0000
3101 \labelwidthstring 00.00.0000
3102
3102
3103
3103
3104 \family typewriter
3104 \family typewriter
3105 \SpecialChar ~
3105 \SpecialChar ~
3106
3106
3107 \family default
3107 \family default
3108 3.
3108 3.
3109
3109
3110 \family typewriter
3110 \family typewriter
3111 $HOME/.ipython/ipythonrc-numeric
3111 $HOME/.ipython/ipythonrc-numeric
3112 \family default
3112 \family default
3113 : load (1) and Numeric and plotting modules.
3113 : load (1) and Numeric and plotting modules.
3114 \layout List
3114 \layout List
3115 \labelwidthstring 00.00.0000
3115 \labelwidthstring 00.00.0000
3116
3116
3117 \SpecialChar ~
3117 \SpecialChar ~
3118 Since it is possible to create an endless loop by having circular file
3118 Since it is possible to create an endless loop by having circular file
3119 inclusions, IPython will stop if it reaches 15 recursive inclusions.
3119 inclusions, IPython will stop if it reaches 15 recursive inclusions.
3120 \layout List
3120 \layout List
3121 \labelwidthstring 00.00.0000
3121 \labelwidthstring 00.00.0000
3122
3122
3123
3123
3124 \family typewriter
3124 \family typewriter
3125 \series bold
3125 \series bold
3126 -prompt_in1|pi1\SpecialChar ~
3126 -prompt_in1|pi1\SpecialChar ~
3127 <string>:
3127 <string>:
3128 \family default
3128 \family default
3129 \series default
3129 \series default
3130 Specify the string used for input prompts.
3130 Specify the string used for input prompts.
3131 Note that if you are using numbered prompts, the number is represented
3131 Note that if you are using numbered prompts, the number is represented
3132 with a '
3132 with a '
3133 \backslash
3133 \backslash
3134 #' in the string.
3134 #' in the string.
3135 Don't forget to quote strings with spaces embedded in them.
3135 Don't forget to quote strings with spaces embedded in them.
3136 Default: '
3136 Default: '
3137 \family typewriter
3137 \family typewriter
3138 In\SpecialChar ~
3138 In\SpecialChar ~
3139 [
3139 [
3140 \backslash
3140 \backslash
3141 #]:
3141 #]:
3142 \family default
3142 \family default
3143 '.
3143 '.
3144 Sec.\SpecialChar ~
3144 Sec.\SpecialChar ~
3145
3145
3146 \begin_inset LatexCommand \ref{sec:prompts}
3146 \begin_inset LatexCommand \ref{sec:prompts}
3147
3147
3148 \end_inset
3148 \end_inset
3149
3149
3150 discusses in detail all the available escapes to customize your prompts.
3150 discusses in detail all the available escapes to customize your prompts.
3151 \layout List
3151 \layout List
3152 \labelwidthstring 00.00.0000
3152 \labelwidthstring 00.00.0000
3153
3153
3154
3154
3155 \family typewriter
3155 \family typewriter
3156 \series bold
3156 \series bold
3157 -prompt_in2|pi2\SpecialChar ~
3157 -prompt_in2|pi2\SpecialChar ~
3158 <string>:
3158 <string>:
3159 \family default
3159 \family default
3160 \series default
3160 \series default
3161 Similar to the previous option, but used for the continuation prompts.
3161 Similar to the previous option, but used for the continuation prompts.
3162 The special sequence '
3162 The special sequence '
3163 \family typewriter
3163 \family typewriter
3164
3164
3165 \backslash
3165 \backslash
3166 D
3166 D
3167 \family default
3167 \family default
3168 ' is similar to '
3168 ' is similar to '
3169 \family typewriter
3169 \family typewriter
3170
3170
3171 \backslash
3171 \backslash
3172 #
3172 #
3173 \family default
3173 \family default
3174 ', but with all digits replaced dots (so you can have your continuation
3174 ', but with all digits replaced dots (so you can have your continuation
3175 prompt aligned with your input prompt).
3175 prompt aligned with your input prompt).
3176 Default: '
3176 Default: '
3177 \family typewriter
3177 \family typewriter
3178 \SpecialChar ~
3178 \SpecialChar ~
3179 \SpecialChar ~
3179 \SpecialChar ~
3180 \SpecialChar ~
3180 \SpecialChar ~
3181 .
3181 .
3182 \backslash
3182 \backslash
3183 D.:
3183 D.:
3184 \family default
3184 \family default
3185 ' (note three spaces at the start for alignment with '
3185 ' (note three spaces at the start for alignment with '
3186 \family typewriter
3186 \family typewriter
3187 In\SpecialChar ~
3187 In\SpecialChar ~
3188 [
3188 [
3189 \backslash
3189 \backslash
3190 #]
3190 #]
3191 \family default
3191 \family default
3192 ').
3192 ').
3193 \layout List
3193 \layout List
3194 \labelwidthstring 00.00.0000
3194 \labelwidthstring 00.00.0000
3195
3195
3196
3196
3197 \family typewriter
3197 \family typewriter
3198 \series bold
3198 \series bold
3199 -prompt_out|po\SpecialChar ~
3199 -prompt_out|po\SpecialChar ~
3200 <string>:
3200 <string>:
3201 \family default
3201 \family default
3202 \series default
3202 \series default
3203 String used for output prompts, also uses numbers like
3203 String used for output prompts, also uses numbers like
3204 \family typewriter
3204 \family typewriter
3205 prompt_in1
3205 prompt_in1
3206 \family default
3206 \family default
3207 .
3207 .
3208 Default: '
3208 Default: '
3209 \family typewriter
3209 \family typewriter
3210 Out[
3210 Out[
3211 \backslash
3211 \backslash
3212 #]:
3212 #]:
3213 \family default
3213 \family default
3214 '
3214 '
3215 \layout List
3215 \layout List
3216 \labelwidthstring 00.00.0000
3216 \labelwidthstring 00.00.0000
3217
3217
3218
3218
3219 \family typewriter
3219 \family typewriter
3220 \series bold
3220 \series bold
3221 -quick
3221 -quick
3222 \family default
3222 \family default
3223 \series default
3223 \series default
3224 : start in bare bones mode (no config file loaded).
3224 : start in bare bones mode (no config file loaded).
3225 \layout List
3225 \layout List
3226 \labelwidthstring 00.00.0000
3226 \labelwidthstring 00.00.0000
3227
3227
3228
3228
3229 \family typewriter
3229 \family typewriter
3230 \series bold
3230 \series bold
3231 -rcfile\SpecialChar ~
3231 -rcfile\SpecialChar ~
3232 <name>
3232 <name>
3233 \series default
3233 \series default
3234 :
3234 :
3235 \family default
3235 \family default
3236 name of your IPython resource configuration file.
3236 name of your IPython resource configuration file.
3237 Normally IPython loads ipythonrc (from current directory) or
3237 Normally IPython loads ipythonrc (from current directory) or
3238 \family typewriter
3238 \family typewriter
3239 IPYTHONDIR/ipythonrc
3239 IPYTHONDIR/ipythonrc
3240 \family default
3240 \family default
3241 .
3241 .
3242 \layout List
3242 \layout List
3243 \labelwidthstring 00.00.0000
3243 \labelwidthstring 00.00.0000
3244
3244
3245 \SpecialChar ~
3245 \SpecialChar ~
3246 If the loading of your config file fails, IPython starts with a bare bones
3246 If the loading of your config file fails, IPython starts with a bare bones
3247 configuration (no modules loaded at all).
3247 configuration (no modules loaded at all).
3248 \layout List
3248 \layout List
3249 \labelwidthstring 00.00.0000
3249 \labelwidthstring 00.00.0000
3250
3250
3251
3251
3252 \family typewriter
3252 \family typewriter
3253 \series bold
3253 \series bold
3254 -no|readline
3254 -[no]readline
3255 \family default
3255 \family default
3256 \series default
3256 \series default
3257 : use the readline library, which is needed to support name completion and
3257 : use the readline library, which is needed to support name completion and
3258 command history, among other things.
3258 command history, among other things.
3259 It is enabled by default, but may cause problems for users of X/Emacs in
3259 It is enabled by default, but may cause problems for users of X/Emacs in
3260 Python comint or shell buffers.
3260 Python comint or shell buffers.
3261 \layout List
3261 \layout List
3262 \labelwidthstring 00.00.0000
3262 \labelwidthstring 00.00.0000
3263
3263
3264 \SpecialChar ~
3264 \SpecialChar ~
3265 Note that X/Emacs 'eterm' buffers (opened with
3265 Note that X/Emacs 'eterm' buffers (opened with
3266 \family typewriter
3266 \family typewriter
3267 M-x\SpecialChar ~
3267 M-x\SpecialChar ~
3268 term
3268 term
3269 \family default
3269 \family default
3270 ) support IPython's readline and syntax coloring fine, only 'emacs' (
3270 ) support IPython's readline and syntax coloring fine, only 'emacs' (
3271 \family typewriter
3271 \family typewriter
3272 M-x\SpecialChar ~
3272 M-x\SpecialChar ~
3273 shell
3273 shell
3274 \family default
3274 \family default
3275 and
3275 and
3276 \family typewriter
3276 \family typewriter
3277 C-c\SpecialChar ~
3277 C-c\SpecialChar ~
3278 !
3278 !
3279 \family default
3279 \family default
3280 ) buffers do not.
3280 ) buffers do not.
3281 \layout List
3281 \layout List
3282 \labelwidthstring 00.00.0000
3282 \labelwidthstring 00.00.0000
3283
3283
3284
3284
3285 \family typewriter
3285 \family typewriter
3286 \series bold
3286 \series bold
3287 -screen_length|sl\SpecialChar ~
3287 -screen_length|sl\SpecialChar ~
3288 <n>
3288 <n>
3289 \series default
3289 \series default
3290 :
3290 :
3291 \family default
3291 \family default
3292 number of lines of your screen.
3292 number of lines of your screen.
3293 This is used to control printing of very long strings.
3293 This is used to control printing of very long strings.
3294 Strings longer than this number of lines will be sent through a pager instead
3294 Strings longer than this number of lines will be sent through a pager instead
3295 of directly printed.
3295 of directly printed.
3296 \layout List
3296 \layout List
3297 \labelwidthstring 00.00.0000
3297 \labelwidthstring 00.00.0000
3298
3298
3299 \SpecialChar ~
3299 \SpecialChar ~
3300 The default value for this is 0, which means IPython will auto-detect your
3300 The default value for this is 0, which means IPython will auto-detect your
3301 screen size every time it needs to print certain potentially long strings
3301 screen size every time it needs to print certain potentially long strings
3302 (this doesn't change the behavior of the 'print' keyword, it's only triggered
3302 (this doesn't change the behavior of the 'print' keyword, it's only triggered
3303 internally).
3303 internally).
3304 If for some reason this isn't working well (it needs curses support), specify
3304 If for some reason this isn't working well (it needs curses support), specify
3305 it yourself.
3305 it yourself.
3306 Otherwise don't change the default.
3306 Otherwise don't change the default.
3307 \layout List
3307 \layout List
3308 \labelwidthstring 00.00.0000
3308 \labelwidthstring 00.00.0000
3309
3309
3310
3310
3311 \family typewriter
3311 \family typewriter
3312 \series bold
3312 \series bold
3313 -separate_in|si\SpecialChar ~
3313 -separate_in|si\SpecialChar ~
3314 <string>
3314 <string>
3315 \series default
3315 \series default
3316 :
3316 :
3317 \family default
3317 \family default
3318 separator before input prompts.
3318 separator before input prompts.
3319 Default: '
3319 Default: '
3320 \family typewriter
3320 \family typewriter
3321
3321
3322 \backslash
3322 \backslash
3323 n
3323 n
3324 \family default
3324 \family default
3325 '
3325 '
3326 \layout List
3326 \layout List
3327 \labelwidthstring 00.00.0000
3327 \labelwidthstring 00.00.0000
3328
3328
3329
3329
3330 \family typewriter
3330 \family typewriter
3331 \series bold
3331 \series bold
3332 -separate_out|so\SpecialChar ~
3332 -separate_out|so\SpecialChar ~
3333 <string>
3333 <string>
3334 \family default
3334 \family default
3335 \series default
3335 \series default
3336 : separator before output prompts.
3336 : separator before output prompts.
3337 Default: nothing.
3337 Default: nothing.
3338 \layout List
3338 \layout List
3339 \labelwidthstring 00.00.0000
3339 \labelwidthstring 00.00.0000
3340
3340
3341
3341
3342 \family typewriter
3342 \family typewriter
3343 \series bold
3343 \series bold
3344 -separate_out2|so2\SpecialChar ~
3344 -separate_out2|so2\SpecialChar ~
3345 <string>
3345 <string>
3346 \series default
3346 \series default
3347 :
3347 :
3348 \family default
3348 \family default
3349 separator after output prompts.
3349 separator after output prompts.
3350 Default: nothing.
3350 Default: nothing.
3351 \layout List
3351 \layout List
3352 \labelwidthstring 00.00.0000
3352 \labelwidthstring 00.00.0000
3353
3353
3354 \SpecialChar ~
3354 \SpecialChar ~
3355 For these three options, use the value 0 to specify no separator.
3355 For these three options, use the value 0 to specify no separator.
3356 \layout List
3356 \layout List
3357 \labelwidthstring 00.00.0000
3357 \labelwidthstring 00.00.0000
3358
3358
3359
3359
3360 \family typewriter
3360 \family typewriter
3361 \series bold
3361 \series bold
3362 -nosep
3362 -nosep
3363 \series default
3363 \series default
3364 :
3364 :
3365 \family default
3365 \family default
3366 shorthand for
3366 shorthand for
3367 \family typewriter
3367 \family typewriter
3368 '-SeparateIn 0 -SeparateOut 0 -SeparateOut2 0'
3368 '-SeparateIn 0 -SeparateOut 0 -SeparateOut2 0'
3369 \family default
3369 \family default
3370 .
3370 .
3371 Simply removes all input/output separators.
3371 Simply removes all input/output separators.
3372 \layout List
3372 \layout List
3373 \labelwidthstring 00.00.0000
3373 \labelwidthstring 00.00.0000
3374
3374
3375
3375
3376 \family typewriter
3376 \family typewriter
3377 \series bold
3377 \series bold
3378 -upgrade
3378 -upgrade
3379 \family default
3379 \family default
3380 \series default
3380 \series default
3381 : allows you to upgrade your
3381 : allows you to upgrade your
3382 \family typewriter
3382 \family typewriter
3383 IPYTHONDIR
3383 IPYTHONDIR
3384 \family default
3384 \family default
3385 configuration when you install a new version of IPython.
3385 configuration when you install a new version of IPython.
3386 Since new versions may include new command line options or example files,
3386 Since new versions may include new command line options or example files,
3387 this copies updated ipythonrc-type files.
3387 this copies updated ipythonrc-type files.
3388 However, it backs up (with a
3388 However, it backs up (with a
3389 \family typewriter
3389 \family typewriter
3390 .old
3390 .old
3391 \family default
3391 \family default
3392 extension) all files which it overwrites so that you can merge back any
3392 extension) all files which it overwrites so that you can merge back any
3393 customizations you might have in your personal files.
3393 customizations you might have in your personal files.
3394 \layout List
3394 \layout List
3395 \labelwidthstring 00.00.0000
3395 \labelwidthstring 00.00.0000
3396
3396
3397
3397
3398 \family typewriter
3398 \family typewriter
3399 \series bold
3399 \series bold
3400 -Version
3400 -Version
3401 \series default
3401 \series default
3402 :
3402 :
3403 \family default
3403 \family default
3404 print version information and exit.
3404 print version information and exit.
3405 \layout List
3405 \layout List
3406 \labelwidthstring 00.00.0000
3406 \labelwidthstring 00.00.0000
3407
3407
3408
3408
3409 \family typewriter
3409 \family typewriter
3410 \series bold
3410 \series bold
3411 -xmode <modename>
3411 -xmode <modename>
3412 \series default
3412 \series default
3413 :
3413 :
3414 \family default
3414 \family default
3415 Mode for exception reporting.
3415 Mode for exception reporting.
3416 \layout List
3416 \layout List
3417 \labelwidthstring 00.00.0000
3417 \labelwidthstring 00.00.0000
3418
3418
3419 \SpecialChar ~
3419 \SpecialChar ~
3420 Valid modes: Plain, Context and Verbose.
3420 Valid modes: Plain, Context and Verbose.
3421 \layout List
3421 \layout List
3422 \labelwidthstring 00.00.0000
3422 \labelwidthstring 00.00.0000
3423
3423
3424 \SpecialChar ~
3424 \SpecialChar ~
3425 Plain: similar to python's normal traceback printing.
3425 Plain: similar to python's normal traceback printing.
3426 \layout List
3426 \layout List
3427 \labelwidthstring 00.00.0000
3427 \labelwidthstring 00.00.0000
3428
3428
3429 \SpecialChar ~
3429 \SpecialChar ~
3430 Context: prints 5 lines of context source code around each line in the
3430 Context: prints 5 lines of context source code around each line in the
3431 traceback.
3431 traceback.
3432 \layout List
3432 \layout List
3433 \labelwidthstring 00.00.0000
3433 \labelwidthstring 00.00.0000
3434
3434
3435 \SpecialChar ~
3435 \SpecialChar ~
3436 Verbose: similar to Context, but additionally prints the variables currently
3436 Verbose: similar to Context, but additionally prints the variables currently
3437 visible where the exception happened (shortening their strings if too long).
3437 visible where the exception happened (shortening their strings if too long).
3438 This can potentially be very slow, if you happen to have a huge data structure
3438 This can potentially be very slow, if you happen to have a huge data structure
3439 whose string representation is complex to compute.
3439 whose string representation is complex to compute.
3440 Your computer may appear to freeze for a while with cpu usage at 100%.
3440 Your computer may appear to freeze for a while with cpu usage at 100%.
3441 If this occurs, you can cancel the traceback with Ctrl-C (maybe hitting
3441 If this occurs, you can cancel the traceback with Ctrl-C (maybe hitting
3442 it more than once).
3442 it more than once).
3443 \layout Section
3443 \layout Section
3444
3444
3445 Interactive use
3445 Interactive use
3446 \layout Standard
3446 \layout Standard
3447
3447
3448
3448
3449 \series bold
3449 \series bold
3450 Warning
3450 Warning
3451 \series default
3451 \series default
3452 : IPython relies on the existence of a global variable called
3452 : IPython relies on the existence of a global variable called
3453 \family typewriter
3453 \family typewriter
3454 __IP
3454 __IP
3455 \family default
3455 \family default
3456 which controls the shell itself.
3456 which controls the shell itself.
3457 If you redefine
3457 If you redefine
3458 \family typewriter
3458 \family typewriter
3459 __IP
3459 __IP
3460 \family default
3460 \family default
3461 to anything, bizarre behavior will quickly occur.
3461 to anything, bizarre behavior will quickly occur.
3462 \layout Standard
3462 \layout Standard
3463
3463
3464 Other than the above warning, IPython is meant to work as a drop-in replacement
3464 Other than the above warning, IPython is meant to work as a drop-in replacement
3465 for the standard interactive interpreter.
3465 for the standard interactive interpreter.
3466 As such, any code which is valid python should execute normally under IPython
3466 As such, any code which is valid python should execute normally under IPython
3467 (cases where this is not true should be reported as bugs).
3467 (cases where this is not true should be reported as bugs).
3468 It does, however, offer many features which are not available at a standard
3468 It does, however, offer many features which are not available at a standard
3469 python prompt.
3469 python prompt.
3470 What follows is a list of these.
3470 What follows is a list of these.
3471 \layout Subsection
3471 \layout Subsection
3472
3472
3473 Caution for Windows users
3473 Caution for Windows users
3474 \layout Standard
3474 \layout Standard
3475
3475
3476 Windows, unfortunately, uses the `
3476 Windows, unfortunately, uses the `
3477 \family typewriter
3477 \family typewriter
3478
3478
3479 \backslash
3479 \backslash
3480
3480
3481 \family default
3481 \family default
3482 ' character as a path separator.
3482 ' character as a path separator.
3483 This is a terrible choice, because `
3483 This is a terrible choice, because `
3484 \family typewriter
3484 \family typewriter
3485
3485
3486 \backslash
3486 \backslash
3487
3487
3488 \family default
3488 \family default
3489 ' also represents the escape character in most modern programming languages,
3489 ' also represents the escape character in most modern programming languages,
3490 including Python.
3490 including Python.
3491 For this reason, issuing many of the commands discussed below (especially
3491 For this reason, issuing many of the commands discussed below (especially
3492 magics which affect the filesystem) with `
3492 magics which affect the filesystem) with `
3493 \family typewriter
3493 \family typewriter
3494
3494
3495 \backslash
3495 \backslash
3496
3496
3497 \family default
3497 \family default
3498 ' in them will cause strange errors.
3498 ' in them will cause strange errors.
3499 \layout Standard
3499 \layout Standard
3500
3500
3501 A partial solution is to use instead the `
3501 A partial solution is to use instead the `
3502 \family typewriter
3502 \family typewriter
3503 /
3503 /
3504 \family default
3504 \family default
3505 ' character as a path separator, which Windows recognizes in
3505 ' character as a path separator, which Windows recognizes in
3506 \emph on
3506 \emph on
3507 most
3507 most
3508 \emph default
3508 \emph default
3509 situations.
3509 situations.
3510 However, in Windows commands `
3510 However, in Windows commands `
3511 \family typewriter
3511 \family typewriter
3512 /
3512 /
3513 \family default
3513 \family default
3514 ' flags options, so you can not use it for the root directory.
3514 ' flags options, so you can not use it for the root directory.
3515 This means that paths beginning at the root must be typed in a contrived
3515 This means that paths beginning at the root must be typed in a contrived
3516 manner like:
3516 manner like:
3517 \newline
3517 \newline
3518
3518
3519 \family typewriter
3519 \family typewriter
3520 %copy
3520 %copy
3521 \backslash
3521 \backslash
3522 opt/foo/bar.txt
3522 opt/foo/bar.txt
3523 \backslash
3523 \backslash
3524 tmp
3524 tmp
3525 \layout Standard
3525 \layout Standard
3526
3526
3527 There is no sensible thing IPython can do to truly work around this flaw
3527 There is no sensible thing IPython can do to truly work around this flaw
3528 in Windows
3528 in Windows
3529 \begin_inset Foot
3529 \begin_inset Foot
3530 collapsed true
3530 collapsed true
3531
3531
3532 \layout Standard
3532 \layout Standard
3533
3533
3534 If anyone comes up with a
3534 If anyone comes up with a
3535 \emph on
3535 \emph on
3536 clean
3536 clean
3537 \emph default
3537 \emph default
3538 solution which works consistently and does not negatively impact other
3538 solution which works consistently and does not negatively impact other
3539 platforms at all, I'll gladly accept a patch.
3539 platforms at all, I'll gladly accept a patch.
3540 \end_inset
3540 \end_inset
3541
3541
3542 .
3542 .
3543 \layout Subsection
3543 \layout Subsection
3544
3544
3545
3545
3546 \begin_inset LatexCommand \label{sec:magic}
3546 \begin_inset LatexCommand \label{sec:magic}
3547
3547
3548 \end_inset
3548 \end_inset
3549
3549
3550 Magic command system
3550 Magic command system
3551 \layout Standard
3551 \layout Standard
3552
3552
3553 IPython will treat any line whose first character is a
3553 IPython will treat any line whose first character is a
3554 \family typewriter
3554 \family typewriter
3555 %
3555 %
3556 \family default
3556 \family default
3557 as a special call to a 'magic' function.
3557 as a special call to a 'magic' function.
3558 These allow you to control the behavior of IPython itself, plus a lot of
3558 These allow you to control the behavior of IPython itself, plus a lot of
3559 system-type features.
3559 system-type features.
3560 They are all prefixed with a
3560 They are all prefixed with a
3561 \family typewriter
3561 \family typewriter
3562 %
3562 %
3563 \family default
3563 \family default
3564 character, but parameters are given without parentheses or quotes.
3564 character, but parameters are given without parentheses or quotes.
3565 \layout Standard
3565 \layout Standard
3566
3566
3567 Example: typing
3567 Example: typing
3568 \family typewriter
3568 \family typewriter
3569 '%cd mydir'
3569 '%cd mydir'
3570 \family default
3570 \family default
3571 (without the quotes) changes you working directory to
3571 (without the quotes) changes you working directory to
3572 \family typewriter
3572 \family typewriter
3573 'mydir'
3573 'mydir'
3574 \family default
3574 \family default
3575 , if it exists.
3575 , if it exists.
3576 \layout Standard
3576 \layout Standard
3577
3577
3578 If you have 'automagic' enabled (in your
3578 If you have 'automagic' enabled (in your
3579 \family typewriter
3579 \family typewriter
3580 ipythonrc
3580 ipythonrc
3581 \family default
3581 \family default
3582 file, via the command line option
3582 file, via the command line option
3583 \family typewriter
3583 \family typewriter
3584 -automagic
3584 -automagic
3585 \family default
3585 \family default
3586 or with the
3586 or with the
3587 \family typewriter
3587 \family typewriter
3588 %automagic
3588 %automagic
3589 \family default
3589 \family default
3590 function), you don't need to type in the
3590 function), you don't need to type in the
3591 \family typewriter
3591 \family typewriter
3592 %
3592 %
3593 \family default
3593 \family default
3594 explicitly.
3594 explicitly.
3595 IPython will scan its internal list of magic functions and call one if
3595 IPython will scan its internal list of magic functions and call one if
3596 it exists.
3596 it exists.
3597 With automagic on you can then just type '
3597 With automagic on you can then just type '
3598 \family typewriter
3598 \family typewriter
3599 cd mydir
3599 cd mydir
3600 \family default
3600 \family default
3601 ' to go to directory '
3601 ' to go to directory '
3602 \family typewriter
3602 \family typewriter
3603 mydir
3603 mydir
3604 \family default
3604 \family default
3605 '.
3605 '.
3606 The automagic system has the lowest possible precedence in name searches,
3606 The automagic system has the lowest possible precedence in name searches,
3607 so defining an identifier with the same name as an existing magic function
3607 so defining an identifier with the same name as an existing magic function
3608 will shadow it for automagic use.
3608 will shadow it for automagic use.
3609 You can still access the shadowed magic function by explicitly using the
3609 You can still access the shadowed magic function by explicitly using the
3610
3610
3611 \family typewriter
3611 \family typewriter
3612 %
3612 %
3613 \family default
3613 \family default
3614 character at the beginning of the line.
3614 character at the beginning of the line.
3615 \layout Standard
3615 \layout Standard
3616
3616
3617 An example (with automagic on) should clarify all this:
3617 An example (with automagic on) should clarify all this:
3618 \layout LyX-Code
3618 \layout LyX-Code
3619
3619
3620 In [1]: cd ipython # %cd is called by automagic
3620 In [1]: cd ipython # %cd is called by automagic
3621 \layout LyX-Code
3621 \layout LyX-Code
3622
3622
3623 /home/fperez/ipython
3623 /home/fperez/ipython
3624 \layout LyX-Code
3624 \layout LyX-Code
3625
3625
3626 In [2]: cd=1 # now cd is just a variable
3626 In [2]: cd=1 # now cd is just a variable
3627 \layout LyX-Code
3627 \layout LyX-Code
3628
3628
3629 In [3]: cd ..
3629 In [3]: cd ..
3630 # and doesn't work as a function anymore
3630 # and doesn't work as a function anymore
3631 \layout LyX-Code
3631 \layout LyX-Code
3632
3632
3633 ------------------------------------------------------------
3633 ------------------------------------------------------------
3634 \layout LyX-Code
3634 \layout LyX-Code
3635
3635
3636 File "<console>", line 1
3636 File "<console>", line 1
3637 \layout LyX-Code
3637 \layout LyX-Code
3638
3638
3639 cd ..
3639 cd ..
3640 \layout LyX-Code
3640 \layout LyX-Code
3641
3641
3642 ^
3642 ^
3643 \layout LyX-Code
3643 \layout LyX-Code
3644
3644
3645 SyntaxError: invalid syntax
3645 SyntaxError: invalid syntax
3646 \layout LyX-Code
3646 \layout LyX-Code
3647
3647
3648 \layout LyX-Code
3648 \layout LyX-Code
3649
3649
3650 In [4]: %cd ..
3650 In [4]: %cd ..
3651 # but %cd always works
3651 # but %cd always works
3652 \layout LyX-Code
3652 \layout LyX-Code
3653
3653
3654 /home/fperez
3654 /home/fperez
3655 \layout LyX-Code
3655 \layout LyX-Code
3656
3656
3657 In [5]: del cd # if you remove the cd variable
3657 In [5]: del cd # if you remove the cd variable
3658 \layout LyX-Code
3658 \layout LyX-Code
3659
3659
3660 In [6]: cd ipython # automagic can work again
3660 In [6]: cd ipython # automagic can work again
3661 \layout LyX-Code
3661 \layout LyX-Code
3662
3662
3663 /home/fperez/ipython
3663 /home/fperez/ipython
3664 \layout Standard
3664 \layout Standard
3665
3665
3666 You can define your own magic functions to extend the system.
3666 You can define your own magic functions to extend the system.
3667 The following is a snippet of code which shows how to do it.
3667 The following is a snippet of code which shows how to do it.
3668 It is provided as file
3668 It is provided as file
3669 \family typewriter
3669 \family typewriter
3670 example-magic.py
3670 example-magic.py
3671 \family default
3671 \family default
3672 in the examples directory:
3672 in the examples directory:
3673 \layout Standard
3673 \layout Standard
3674
3674
3675
3675
3676 \begin_inset ERT
3676 \begin_inset ERT
3677 status Open
3677 status Open
3678
3678
3679 \layout Standard
3679 \layout Standard
3680
3680
3681 \backslash
3681 \backslash
3682 codelist{examples/example-magic.py}
3682 codelist{examples/example-magic.py}
3683 \end_inset
3683 \end_inset
3684
3684
3685
3685
3686 \layout Standard
3686 \layout Standard
3687
3687
3688 You can also define your own aliased names for magic functions.
3688 You can also define your own aliased names for magic functions.
3689 In your
3689 In your
3690 \family typewriter
3690 \family typewriter
3691 ipythonrc
3691 ipythonrc
3692 \family default
3692 \family default
3693 file, placing a line like:
3693 file, placing a line like:
3694 \layout Standard
3694 \layout Standard
3695
3695
3696
3696
3697 \family typewriter
3697 \family typewriter
3698 execute __IP.magic_cl = __IP.magic_clear
3698 execute __IP.magic_cl = __IP.magic_clear
3699 \layout Standard
3699 \layout Standard
3700
3700
3701 will define
3701 will define
3702 \family typewriter
3702 \family typewriter
3703 %cl
3703 %cl
3704 \family default
3704 \family default
3705 as a new name for
3705 as a new name for
3706 \family typewriter
3706 \family typewriter
3707 %clear
3707 %clear
3708 \family default
3708 \family default
3709 .
3709 .
3710 \layout Standard
3710 \layout Standard
3711
3711
3712 Type
3712 Type
3713 \family typewriter
3713 \family typewriter
3714 %magic
3714 %magic
3715 \family default
3715 \family default
3716 for more information, including a list of all available magic functions
3716 for more information, including a list of all available magic functions
3717 at any time and their docstrings.
3717 at any time and their docstrings.
3718 You can also type
3718 You can also type
3719 \family typewriter
3719 \family typewriter
3720 %magic_function_name?
3720 %magic_function_name?
3721 \family default
3721 \family default
3722 (see sec.
3722 (see sec.
3723
3723
3724 \begin_inset LatexCommand \ref{sec:dyn-object-info}
3724 \begin_inset LatexCommand \ref{sec:dyn-object-info}
3725
3725
3726 \end_inset
3726 \end_inset
3727
3727
3728 for information on the
3728 for information on the
3729 \family typewriter
3729 \family typewriter
3730 '?'
3730 '?'
3731 \family default
3731 \family default
3732 system) to get information about any particular magic function you are
3732 system) to get information about any particular magic function you are
3733 interested in.
3733 interested in.
3734 \layout Subsubsection
3734 \layout Subsubsection
3735
3735
3736 Magic commands
3736 Magic commands
3737 \layout Standard
3737 \layout Standard
3738
3738
3739 The rest of this section is automatically generated for each release from
3739 The rest of this section is automatically generated for each release from
3740 the docstrings in the IPython code.
3740 the docstrings in the IPython code.
3741 Therefore the formatting is somewhat minimal, but this method has the advantage
3741 Therefore the formatting is somewhat minimal, but this method has the advantage
3742 of having information always in sync with the code.
3742 of having information always in sync with the code.
3743 \layout Standard
3743 \layout Standard
3744
3744
3745 A list of all the magic commands available in IPython's
3745 A list of all the magic commands available in IPython's
3746 \emph on
3746 \emph on
3747 default
3747 default
3748 \emph default
3748 \emph default
3749 installation follows.
3749 installation follows.
3750 This is similar to what you'll see by simply typing
3750 This is similar to what you'll see by simply typing
3751 \family typewriter
3751 \family typewriter
3752 %magic
3752 %magic
3753 \family default
3753 \family default
3754 at the prompt, but that will also give you information about magic commands
3754 at the prompt, but that will also give you information about magic commands
3755 you may have added as part of your personal customizations.
3755 you may have added as part of your personal customizations.
3756 \layout Standard
3756 \layout Standard
3757
3757
3758
3758
3759 \begin_inset Include \input{magic.tex}
3759 \begin_inset Include \input{magic.tex}
3760 preview false
3760 preview false
3761
3761
3762 \end_inset
3762 \end_inset
3763
3763
3764
3764
3765 \layout Subsection
3765 \layout Subsection
3766
3766
3767 Access to the standard Python help
3767 Access to the standard Python help
3768 \layout Standard
3768 \layout Standard
3769
3769
3770 As of Python 2.1, a help system is available with access to object docstrings
3770 As of Python 2.1, a help system is available with access to object docstrings
3771 and the Python manuals.
3771 and the Python manuals.
3772 Simply type
3772 Simply type
3773 \family typewriter
3773 \family typewriter
3774 'help'
3774 'help'
3775 \family default
3775 \family default
3776 (no quotes) to access it.
3776 (no quotes) to access it.
3777 You can also type
3777 You can also type
3778 \family typewriter
3778 \family typewriter
3779 help(object)
3779 help(object)
3780 \family default
3780 \family default
3781 to obtain information about a given object, and
3781 to obtain information about a given object, and
3782 \family typewriter
3782 \family typewriter
3783 help('keyword')
3783 help('keyword')
3784 \family default
3784 \family default
3785 for information on a keyword.
3785 for information on a keyword.
3786 As noted in sec.
3786 As noted in sec.
3787
3787
3788 \begin_inset LatexCommand \ref{sec:help-access}
3788 \begin_inset LatexCommand \ref{sec:help-access}
3789
3789
3790 \end_inset
3790 \end_inset
3791
3791
3792 , you need to properly configure your environment variable
3792 , you need to properly configure your environment variable
3793 \family typewriter
3793 \family typewriter
3794 PYTHONDOCS
3794 PYTHONDOCS
3795 \family default
3795 \family default
3796 for this feature to work correctly.
3796 for this feature to work correctly.
3797 \layout Subsection
3797 \layout Subsection
3798
3798
3799
3799
3800 \begin_inset LatexCommand \label{sec:dyn-object-info}
3800 \begin_inset LatexCommand \label{sec:dyn-object-info}
3801
3801
3802 \end_inset
3802 \end_inset
3803
3803
3804 Dynamic object information
3804 Dynamic object information
3805 \layout Standard
3805 \layout Standard
3806
3806
3807 Typing
3807 Typing
3808 \family typewriter
3808 \family typewriter
3809 ?word
3809 ?word
3810 \family default
3810 \family default
3811 or
3811 or
3812 \family typewriter
3812 \family typewriter
3813 word?
3813 word?
3814 \family default
3814 \family default
3815 prints detailed information about an object.
3815 prints detailed information about an object.
3816 If certain strings in the object are too long (docstrings, code, etc.) they
3816 If certain strings in the object are too long (docstrings, code, etc.) they
3817 get snipped in the center for brevity.
3817 get snipped in the center for brevity.
3818 This system gives access variable types and values, full source code for
3818 This system gives access variable types and values, full source code for
3819 any object (if available), function prototypes and other useful information.
3819 any object (if available), function prototypes and other useful information.
3820 \layout Standard
3820 \layout Standard
3821
3821
3822 Typing
3822 Typing
3823 \family typewriter
3823 \family typewriter
3824 ??word
3824 ??word
3825 \family default
3825 \family default
3826 or
3826 or
3827 \family typewriter
3827 \family typewriter
3828 word??
3828 word??
3829 \family default
3829 \family default
3830 gives access to the full information without snipping long strings.
3830 gives access to the full information without snipping long strings.
3831 Long strings are sent to the screen through the
3831 Long strings are sent to the screen through the
3832 \family typewriter
3832 \family typewriter
3833 less
3833 less
3834 \family default
3834 \family default
3835 pager if longer than the screen and printed otherwise.
3835 pager if longer than the screen and printed otherwise.
3836 On systems lacking the
3836 On systems lacking the
3837 \family typewriter
3837 \family typewriter
3838 less
3838 less
3839 \family default
3839 \family default
3840 command, IPython uses a very basic internal pager.
3840 command, IPython uses a very basic internal pager.
3841 \layout Standard
3841 \layout Standard
3842
3842
3843 The following magic functions are particularly useful for gathering information
3843 The following magic functions are particularly useful for gathering information
3844 about your working environment.
3844 about your working environment.
3845 You can get more details by typing
3845 You can get more details by typing
3846 \family typewriter
3846 \family typewriter
3847 %magic
3847 %magic
3848 \family default
3848 \family default
3849 or querying them individually (use
3849 or querying them individually (use
3850 \family typewriter
3850 \family typewriter
3851 %function_name?
3851 %function_name?
3852 \family default
3852 \family default
3853 with or without the
3853 with or without the
3854 \family typewriter
3854 \family typewriter
3855 %
3855 %
3856 \family default
3856 \family default
3857 ), this is just a summary:
3857 ), this is just a summary:
3858 \layout List
3858 \layout List
3859 \labelwidthstring 00.00.0000
3859 \labelwidthstring 00.00.0000
3860
3860
3861
3861
3862 \family typewriter
3862 \family typewriter
3863 \series bold
3863 \series bold
3864 %pdoc\SpecialChar ~
3864 %pdoc\SpecialChar ~
3865 <object>
3865 <object>
3866 \family default
3866 \family default
3867 \series default
3867 \series default
3868 : Print (or run through a pager if too long) the docstring for an object.
3868 : Print (or run through a pager if too long) the docstring for an object.
3869 If the given object is a class, it will print both the class and the constructo
3869 If the given object is a class, it will print both the class and the constructo
3870 r docstrings.
3870 r docstrings.
3871 \layout List
3871 \layout List
3872 \labelwidthstring 00.00.0000
3872 \labelwidthstring 00.00.0000
3873
3873
3874
3874
3875 \family typewriter
3875 \family typewriter
3876 \series bold
3876 \series bold
3877 %pdef\SpecialChar ~
3877 %pdef\SpecialChar ~
3878 <object>
3878 <object>
3879 \family default
3879 \family default
3880 \series default
3880 \series default
3881 : Print the definition header for any callable object.
3881 : Print the definition header for any callable object.
3882 If the object is a class, print the constructor information.
3882 If the object is a class, print the constructor information.
3883 \layout List
3883 \layout List
3884 \labelwidthstring 00.00.0000
3884 \labelwidthstring 00.00.0000
3885
3885
3886
3886
3887 \family typewriter
3887 \family typewriter
3888 \series bold
3888 \series bold
3889 %psource\SpecialChar ~
3889 %psource\SpecialChar ~
3890 <object>
3890 <object>
3891 \family default
3891 \family default
3892 \series default
3892 \series default
3893 : Print (or run through a pager if too long) the source code for an object.
3893 : Print (or run through a pager if too long) the source code for an object.
3894 \layout List
3894 \layout List
3895 \labelwidthstring 00.00.0000
3895 \labelwidthstring 00.00.0000
3896
3896
3897
3897
3898 \family typewriter
3898 \family typewriter
3899 \series bold
3899 \series bold
3900 %pfile\SpecialChar ~
3900 %pfile\SpecialChar ~
3901 <object>
3901 <object>
3902 \family default
3902 \family default
3903 \series default
3903 \series default
3904 : Show the entire source file where an object was defined via a pager, opening
3904 : Show the entire source file where an object was defined via a pager, opening
3905 it at the line where the object definition begins.
3905 it at the line where the object definition begins.
3906 \layout List
3906 \layout List
3907 \labelwidthstring 00.00.0000
3907 \labelwidthstring 00.00.0000
3908
3908
3909
3909
3910 \family typewriter
3910 \family typewriter
3911 \series bold
3911 \series bold
3912 %who/%whos
3912 %who/%whos
3913 \family default
3913 \family default
3914 \series default
3914 \series default
3915 : These functions give information about identifiers you have defined interactiv
3915 : These functions give information about identifiers you have defined interactiv
3916 ely (not things you loaded or defined in your configuration files).
3916 ely (not things you loaded or defined in your configuration files).
3917
3917
3918 \family typewriter
3918 \family typewriter
3919 %who
3919 %who
3920 \family default
3920 \family default
3921 just prints a list of identifiers and
3921 just prints a list of identifiers and
3922 \family typewriter
3922 \family typewriter
3923 %whos
3923 %whos
3924 \family default
3924 \family default
3925 prints a table with some basic details about each identifier.
3925 prints a table with some basic details about each identifier.
3926 \layout Standard
3926 \layout Standard
3927
3927
3928 Note that the dynamic object information functions (
3928 Note that the dynamic object information functions (
3929 \family typewriter
3929 \family typewriter
3930 ?/??, %pdoc, %pfile, %pdef, %psource
3930 ?/??, %pdoc, %pfile, %pdef, %psource
3931 \family default
3931 \family default
3932 ) give you access to documentation even on things which are not really defined
3932 ) give you access to documentation even on things which are not really defined
3933 as separate identifiers.
3933 as separate identifiers.
3934 Try for example typing
3934 Try for example typing
3935 \family typewriter
3935 \family typewriter
3936 {}.get?
3936 {}.get?
3937 \family default
3937 \family default
3938 or after doing
3938 or after doing
3939 \family typewriter
3939 \family typewriter
3940 import os
3940 import os
3941 \family default
3941 \family default
3942 , type
3942 , type
3943 \family typewriter
3943 \family typewriter
3944 os.path.abspath??
3944 os.path.abspath??
3945 \family default
3945 \family default
3946 .
3946 .
3947 \layout Subsection
3947 \layout Subsection
3948
3948
3949
3949
3950 \begin_inset LatexCommand \label{sec:readline}
3950 \begin_inset LatexCommand \label{sec:readline}
3951
3951
3952 \end_inset
3952 \end_inset
3953
3953
3954 Readline-based features
3954 Readline-based features
3955 \layout Standard
3955 \layout Standard
3956
3956
3957 These features require the GNU readline library, so they won't work if your
3957 These features require the GNU readline library, so they won't work if your
3958 Python installation lacks readline support.
3958 Python installation lacks readline support.
3959 We will first describe the default behavior IPython uses, and then how
3959 We will first describe the default behavior IPython uses, and then how
3960 to change it to suit your preferences.
3960 to change it to suit your preferences.
3961 \layout Subsubsection
3961 \layout Subsubsection
3962
3962
3963 Command line completion
3963 Command line completion
3964 \layout Standard
3964 \layout Standard
3965
3965
3966 At any time, hitting TAB will complete any available python commands or
3966 At any time, hitting TAB will complete any available python commands or
3967 variable names, and show you a list of the possible completions if there's
3967 variable names, and show you a list of the possible completions if there's
3968 no unambiguous one.
3968 no unambiguous one.
3969 It will also complete filenames in the current directory if no python names
3969 It will also complete filenames in the current directory if no python names
3970 match what you've typed so far.
3970 match what you've typed so far.
3971 \layout Subsubsection
3971 \layout Subsubsection
3972
3972
3973 Search command history
3973 Search command history
3974 \layout Standard
3974 \layout Standard
3975
3975
3976 IPython provides two ways for searching through previous input and thus
3976 IPython provides two ways for searching through previous input and thus
3977 reduce the need for repetitive typing:
3977 reduce the need for repetitive typing:
3978 \layout Enumerate
3978 \layout Enumerate
3979
3979
3980 Start typing, and then use
3980 Start typing, and then use
3981 \family typewriter
3981 \family typewriter
3982 Ctrl-p
3982 Ctrl-p
3983 \family default
3983 \family default
3984 (previous,up) and
3984 (previous,up) and
3985 \family typewriter
3985 \family typewriter
3986 Ctrl-n
3986 Ctrl-n
3987 \family default
3987 \family default
3988 (next,down) to search through only the history items that match what you've
3988 (next,down) to search through only the history items that match what you've
3989 typed so far.
3989 typed so far.
3990 If you use
3990 If you use
3991 \family typewriter
3991 \family typewriter
3992 Ctrl-p/Ctrl-n
3992 Ctrl-p/Ctrl-n
3993 \family default
3993 \family default
3994 at a blank prompt, they just behave like normal arrow keys.
3994 at a blank prompt, they just behave like normal arrow keys.
3995 \layout Enumerate
3995 \layout Enumerate
3996
3996
3997 Hit
3997 Hit
3998 \family typewriter
3998 \family typewriter
3999 Ctrl-r
3999 Ctrl-r
4000 \family default
4000 \family default
4001 : opens a search prompt.
4001 : opens a search prompt.
4002 Begin typing and the system searches your history for lines that contain
4002 Begin typing and the system searches your history for lines that contain
4003 what you've typed so far, completing as much as it can.
4003 what you've typed so far, completing as much as it can.
4004 \layout Subsubsection
4004 \layout Subsubsection
4005
4005
4006 Persistent command history across sessions
4006 Persistent command history across sessions
4007 \layout Standard
4007 \layout Standard
4008
4008
4009 IPython will save your input history when it leaves and reload it next time
4009 IPython will save your input history when it leaves and reload it next time
4010 you restart it.
4010 you restart it.
4011 By default, the history file is named
4011 By default, the history file is named
4012 \family typewriter
4012 \family typewriter
4013 $IPYTHONDIR/history
4013 $IPYTHONDIR/history
4014 \family default
4014 \family default
4015 , but if you've loaded a named profile, '
4015 , but if you've loaded a named profile, '
4016 \family typewriter
4016 \family typewriter
4017 -PROFILE_NAME
4017 -PROFILE_NAME
4018 \family default
4018 \family default
4019 ' is appended to the name.
4019 ' is appended to the name.
4020 This allows you to keep separate histories related to various tasks: commands
4020 This allows you to keep separate histories related to various tasks: commands
4021 related to numerical work will not be clobbered by a system shell history,
4021 related to numerical work will not be clobbered by a system shell history,
4022 for example.
4022 for example.
4023 \layout Subsubsection
4023 \layout Subsubsection
4024
4024
4025 Autoindent
4025 Autoindent
4026 \layout Standard
4026 \layout Standard
4027
4027
4028 IPython can recognize lines ending in ':' and indent the next line, while
4028 IPython can recognize lines ending in ':' and indent the next line, while
4029 also un-indenting automatically after 'raise' or 'return'.
4029 also un-indenting automatically after 'raise' or 'return'.
4030
4030
4031 \layout Standard
4031 \layout Standard
4032
4032
4033 This feature uses the readline library, so it will honor your
4033 This feature uses the readline library, so it will honor your
4034 \family typewriter
4034 \family typewriter
4035 ~/.inputrc
4035 ~/.inputrc
4036 \family default
4036 \family default
4037 configuration (or whatever file your
4037 configuration (or whatever file your
4038 \family typewriter
4038 \family typewriter
4039 INPUTRC
4039 INPUTRC
4040 \family default
4040 \family default
4041 variable points to).
4041 variable points to).
4042 Adding the following lines to your
4042 Adding the following lines to your
4043 \family typewriter
4043 \family typewriter
4044 .inputrc
4044 .inputrc
4045 \family default
4045 \family default
4046 file can make indenting/unindenting more convenient (
4046 file can make indenting/unindenting more convenient (
4047 \family typewriter
4047 \family typewriter
4048 M-i
4048 M-i
4049 \family default
4049 \family default
4050 indents,
4050 indents,
4051 \family typewriter
4051 \family typewriter
4052 M-u
4052 M-u
4053 \family default
4053 \family default
4054 unindents):
4054 unindents):
4055 \layout Standard
4055 \layout Standard
4056
4056
4057
4057
4058 \family typewriter
4058 \family typewriter
4059 $if Python
4059 $if Python
4060 \newline
4060 \newline
4061 "
4061 "
4062 \backslash
4062 \backslash
4063 M-i": "\SpecialChar ~
4063 M-i": "\SpecialChar ~
4064 \SpecialChar ~
4064 \SpecialChar ~
4065 \SpecialChar ~
4065 \SpecialChar ~
4066 \SpecialChar ~
4066 \SpecialChar ~
4067 "
4067 "
4068 \newline
4068 \newline
4069 "
4069 "
4070 \backslash
4070 \backslash
4071 M-u": "
4071 M-u": "
4072 \backslash
4072 \backslash
4073 d
4073 d
4074 \backslash
4074 \backslash
4075 d
4075 d
4076 \backslash
4076 \backslash
4077 d
4077 d
4078 \backslash
4078 \backslash
4079 d"
4079 d"
4080 \newline
4080 \newline
4081 $endif
4081 $endif
4082 \layout Standard
4082 \layout Standard
4083
4083
4084 Note that there are 4 spaces between the quote marks after
4084 Note that there are 4 spaces between the quote marks after
4085 \family typewriter
4085 \family typewriter
4086 "M-i"
4086 "M-i"
4087 \family default
4087 \family default
4088 above.
4088 above.
4089 \layout Standard
4089 \layout Standard
4090
4090
4091
4091
4092 \series bold
4092 \series bold
4093 Warning:
4093 Warning:
4094 \series default
4094 \series default
4095 this feature is ON by default, but it can cause problems with the pasting
4095 this feature is ON by default, but it can cause problems with the pasting
4096 of multi-line indented code (the pasted code gets re-indented on each line).
4096 of multi-line indented code (the pasted code gets re-indented on each line).
4097 A magic function
4097 A magic function
4098 \family typewriter
4098 \family typewriter
4099 %autoindent
4099 %autoindent
4100 \family default
4100 \family default
4101 allows you to toggle it on/off at runtime.
4101 allows you to toggle it on/off at runtime.
4102 You can also disable it permanently on in your
4102 You can also disable it permanently on in your
4103 \family typewriter
4103 \family typewriter
4104 ipythonrc
4104 ipythonrc
4105 \family default
4105 \family default
4106 file (set
4106 file (set
4107 \family typewriter
4107 \family typewriter
4108 autoindent 0
4108 autoindent 0
4109 \family default
4109 \family default
4110 ).
4110 ).
4111 \layout Subsubsection
4111 \layout Subsubsection
4112
4112
4113 Customizing readline behavior
4113 Customizing readline behavior
4114 \layout Standard
4114 \layout Standard
4115
4115
4116 All these features are based on the GNU readline library, which has an extremely
4116 All these features are based on the GNU readline library, which has an extremely
4117 customizable interface.
4117 customizable interface.
4118 Normally, readline is configured via a file which defines the behavior
4118 Normally, readline is configured via a file which defines the behavior
4119 of the library; the details of the syntax for this can be found in the
4119 of the library; the details of the syntax for this can be found in the
4120 readline documentation available with your system or on the Internet.
4120 readline documentation available with your system or on the Internet.
4121 IPython doesn't read this file (if it exists) directly, but it does support
4121 IPython doesn't read this file (if it exists) directly, but it does support
4122 passing to readline valid options via a simple interface.
4122 passing to readline valid options via a simple interface.
4123 In brief, you can customize readline by setting the following options in
4123 In brief, you can customize readline by setting the following options in
4124 your
4124 your
4125 \family typewriter
4125 \family typewriter
4126 ipythonrc
4126 ipythonrc
4127 \family default
4127 \family default
4128 configuration file (note that these options can
4128 configuration file (note that these options can
4129 \emph on
4129 \emph on
4130 not
4130 not
4131 \emph default
4131 \emph default
4132 be specified at the command line):
4132 be specified at the command line):
4133 \layout List
4133 \layout List
4134 \labelwidthstring 00.00.0000
4134 \labelwidthstring 00.00.0000
4135
4135
4136
4136
4137 \family typewriter
4137 \family typewriter
4138 \series bold
4138 \series bold
4139 readline_parse_and_bind:
4139 readline_parse_and_bind:
4140 \family default
4140 \family default
4141 \series default
4141 \series default
4142 this option can appear as many times as you want, each time defining a
4142 this option can appear as many times as you want, each time defining a
4143 string to be executed via a
4143 string to be executed via a
4144 \family typewriter
4144 \family typewriter
4145 readline.parse_and_bind()
4145 readline.parse_and_bind()
4146 \family default
4146 \family default
4147 command.
4147 command.
4148 The syntax for valid commands of this kind can be found by reading the
4148 The syntax for valid commands of this kind can be found by reading the
4149 documentation for the GNU readline library, as these commands are of the
4149 documentation for the GNU readline library, as these commands are of the
4150 kind which readline accepts in its configuration file.
4150 kind which readline accepts in its configuration file.
4151 \layout List
4151 \layout List
4152 \labelwidthstring 00.00.0000
4152 \labelwidthstring 00.00.0000
4153
4153
4154
4154
4155 \family typewriter
4155 \family typewriter
4156 \series bold
4156 \series bold
4157 readline_remove_delims:
4157 readline_remove_delims:
4158 \family default
4158 \family default
4159 \series default
4159 \series default
4160 a string of characters to be removed from the default word-delimiters list
4160 a string of characters to be removed from the default word-delimiters list
4161 used by readline, so that completions may be performed on strings which
4161 used by readline, so that completions may be performed on strings which
4162 contain them.
4162 contain them.
4163 Do not change the default value unless you know what you're doing.
4163 Do not change the default value unless you know what you're doing.
4164 \layout List
4164 \layout List
4165 \labelwidthstring 00.00.0000
4165 \labelwidthstring 00.00.0000
4166
4166
4167
4167
4168 \family typewriter
4168 \family typewriter
4169 \series bold
4169 \series bold
4170 readline_omit__names
4170 readline_omit__names
4171 \family default
4171 \family default
4172 \series default
4172 \series default
4173 : when tab-completion is enabled, hitting
4173 : when tab-completion is enabled, hitting
4174 \family typewriter
4174 \family typewriter
4175 <tab>
4175 <tab>
4176 \family default
4176 \family default
4177 after a '
4177 after a '
4178 \family typewriter
4178 \family typewriter
4179 .
4179 .
4180 \family default
4180 \family default
4181 ' in a name will complete all attributes of an object, including all the
4181 ' in a name will complete all attributes of an object, including all the
4182 special methods whose names include double underscores (like
4182 special methods whose names include double underscores (like
4183 \family typewriter
4183 \family typewriter
4184 __getitem__
4184 __getitem__
4185 \family default
4185 \family default
4186 or
4186 or
4187 \family typewriter
4187 \family typewriter
4188 __class__
4188 __class__
4189 \family default
4189 \family default
4190 ).
4190 ).
4191 If you'd rather not see these names by default, you can set this option
4191 If you'd rather not see these names by default, you can set this option
4192 to 1.
4192 to 1.
4193 Note that even when this option is set, you can still see those names by
4193 Note that even when this option is set, you can still see those names by
4194 explicitly typing a
4194 explicitly typing a
4195 \family typewriter
4195 \family typewriter
4196 _
4196 _
4197 \family default
4197 \family default
4198 after the period and hitting
4198 after the period and hitting
4199 \family typewriter
4199 \family typewriter
4200 <tab>
4200 <tab>
4201 \family default
4201 \family default
4202 : '
4202 : '
4203 \family typewriter
4203 \family typewriter
4204 name._<tab>
4204 name._<tab>
4205 \family default
4205 \family default
4206 ' will always complete attribute names starting with '
4206 ' will always complete attribute names starting with '
4207 \family typewriter
4207 \family typewriter
4208 _
4208 _
4209 \family default
4209 \family default
4210 '.
4210 '.
4211 \layout List
4211 \layout List
4212 \labelwidthstring 00.00.0000
4212 \labelwidthstring 00.00.0000
4213
4213
4214 \SpecialChar ~
4214 \SpecialChar ~
4215 This option is off by default so that new users see all attributes of any
4215 This option is off by default so that new users see all attributes of any
4216 objects they are dealing with.
4216 objects they are dealing with.
4217 \layout Standard
4217 \layout Standard
4218
4218
4219 You will find the default values along with a corresponding detailed explanation
4219 You will find the default values along with a corresponding detailed explanation
4220 in your
4220 in your
4221 \family typewriter
4221 \family typewriter
4222 ipythonrc
4222 ipythonrc
4223 \family default
4223 \family default
4224 file.
4224 file.
4225 \layout Subsection
4225 \layout Subsection
4226
4226
4227 Session logging and restoring
4227 Session logging and restoring
4228 \layout Standard
4228 \layout Standard
4229
4229
4230 You can log all input from a session either by starting IPython with the
4230 You can log all input from a session either by starting IPython with the
4231 command line switches
4231 command line switches
4232 \family typewriter
4232 \family typewriter
4233 -log
4233 -log
4234 \family default
4234 \family default
4235 or
4235 or
4236 \family typewriter
4236 \family typewriter
4237 -logfile
4237 -logfile
4238 \family default
4238 \family default
4239 (see sec.
4239 (see sec.
4240
4240
4241 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
4241 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
4242
4242
4243 \end_inset
4243 \end_inset
4244
4244
4245 )or by activating the logging at any moment with the magic function
4245 )or by activating the logging at any moment with the magic function
4246 \family typewriter
4246 \family typewriter
4247 %logstart
4247 %logstart
4248 \family default
4248 \family default
4249 .
4249 .
4250
4250
4251 \layout Standard
4251 \layout Standard
4252
4252
4253 Log files can later be reloaded with the
4253 Log files can later be reloaded with the
4254 \family typewriter
4254 \family typewriter
4255 -logplay
4255 -logplay
4256 \family default
4256 \family default
4257 option and IPython will attempt to 'replay' the log by executing all the
4257 option and IPython will attempt to 'replay' the log by executing all the
4258 lines in it, thus restoring the state of a previous session.
4258 lines in it, thus restoring the state of a previous session.
4259 This feature is not quite perfect, but can still be useful in many cases.
4259 This feature is not quite perfect, but can still be useful in many cases.
4260 \layout Standard
4260 \layout Standard
4261
4261
4262 The log files can also be used as a way to have a permanent record of any
4262 The log files can also be used as a way to have a permanent record of any
4263 code you wrote while experimenting.
4263 code you wrote while experimenting.
4264 Log files are regular text files which you can later open in your favorite
4264 Log files are regular text files which you can later open in your favorite
4265 text editor to extract code or to 'clean them up' before using them to
4265 text editor to extract code or to 'clean them up' before using them to
4266 replay a session.
4266 replay a session.
4267 \layout Standard
4267 \layout Standard
4268
4268
4269 The
4269 The
4270 \family typewriter
4270 \family typewriter
4271 %logstart
4271 %logstart
4272 \family default
4272 \family default
4273 function for activating logging in mid-session is used as follows:
4273 function for activating logging in mid-session is used as follows:
4274 \layout Standard
4274 \layout Standard
4275
4275
4276
4276
4277 \family typewriter
4277 \family typewriter
4278 %logstart [log_name [log_mode]]
4278 %logstart [log_name [log_mode]]
4279 \layout Standard
4279 \layout Standard
4280
4280
4281 If no name is given, it defaults to a file named
4281 If no name is given, it defaults to a file named
4282 \family typewriter
4282 \family typewriter
4283 'log'
4283 'log'
4284 \family default
4284 \family default
4285 in your IPYTHONDIR directory, in
4285 in your IPYTHONDIR directory, in
4286 \family typewriter
4286 \family typewriter
4287 'rotate'
4287 'rotate'
4288 \family default
4288 \family default
4289 mode (see below).
4289 mode (see below).
4290 \layout Standard
4290 \layout Standard
4291
4291
4292 '
4292 '
4293 \family typewriter
4293 \family typewriter
4294 %logstart name
4294 %logstart name
4295 \family default
4295 \family default
4296 ' saves to file
4296 ' saves to file
4297 \family typewriter
4297 \family typewriter
4298 'name'
4298 'name'
4299 \family default
4299 \family default
4300 in
4300 in
4301 \family typewriter
4301 \family typewriter
4302 'backup'
4302 'backup'
4303 \family default
4303 \family default
4304 mode.
4304 mode.
4305 It saves your history up to that point and then continues logging.
4305 It saves your history up to that point and then continues logging.
4306 \layout Standard
4306 \layout Standard
4307
4307
4308
4308
4309 \family typewriter
4309 \family typewriter
4310 %logstart
4310 %logstart
4311 \family default
4311 \family default
4312 takes a second optional parameter: logging mode.
4312 takes a second optional parameter: logging mode.
4313 This can be one of (note that the modes are given unquoted):
4313 This can be one of (note that the modes are given unquoted):
4314 \layout List
4314 \layout List
4315 \labelwidthstring 00.00.0000
4315 \labelwidthstring 00.00.0000
4316
4316
4317
4317
4318 \family typewriter
4318 \family typewriter
4319 over
4319 over
4320 \family default
4320 \family default
4321 : overwrite existing
4321 : overwrite existing
4322 \family typewriter
4322 \family typewriter
4323 log_name
4323 log_name
4324 \family default
4324 \family default
4325 .
4325 .
4326 \layout List
4326 \layout List
4327 \labelwidthstring 00.00.0000
4327 \labelwidthstring 00.00.0000
4328
4328
4329
4329
4330 \family typewriter
4330 \family typewriter
4331 backup
4331 backup
4332 \family default
4332 \family default
4333 : rename (if exists) to
4333 : rename (if exists) to
4334 \family typewriter
4334 \family typewriter
4335 log_name~
4335 log_name~
4336 \family default
4336 \family default
4337 and start
4337 and start
4338 \family typewriter
4338 \family typewriter
4339 log_name
4339 log_name
4340 \family default
4340 \family default
4341 .
4341 .
4342 \layout List
4342 \layout List
4343 \labelwidthstring 00.00.0000
4343 \labelwidthstring 00.00.0000
4344
4344
4345
4345
4346 \family typewriter
4346 \family typewriter
4347 append
4347 append
4348 \family default
4348 \family default
4349 : well, that says it.
4349 : well, that says it.
4350 \layout List
4350 \layout List
4351 \labelwidthstring 00.00.0000
4351 \labelwidthstring 00.00.0000
4352
4352
4353
4353
4354 \family typewriter
4354 \family typewriter
4355 rotate
4355 rotate
4356 \family default
4356 \family default
4357 : create rotating logs
4357 : create rotating logs
4358 \family typewriter
4358 \family typewriter
4359 log_name
4359 log_name
4360 \family default
4360 \family default
4361 .
4361 .
4362 \family typewriter
4362 \family typewriter
4363 1~
4363 1~
4364 \family default
4364 \family default
4365 ,
4365 ,
4366 \family typewriter
4366 \family typewriter
4367 log_name.2~
4367 log_name.2~
4368 \family default
4368 \family default
4369 , etc.
4369 , etc.
4370 \layout Standard
4370 \layout Standard
4371
4371
4372 The
4372 The
4373 \family typewriter
4373 \family typewriter
4374 %logoff
4374 %logoff
4375 \family default
4375 \family default
4376 and
4376 and
4377 \family typewriter
4377 \family typewriter
4378 %logon
4378 %logon
4379 \family default
4379 \family default
4380 functions allow you to temporarily stop and resume logging to a file which
4380 functions allow you to temporarily stop and resume logging to a file which
4381 had previously been started with
4381 had previously been started with
4382 \family typewriter
4382 \family typewriter
4383 %logstart
4383 %logstart
4384 \family default
4384 \family default
4385 .
4385 .
4386 They will fail (with an explanation) if you try to use them before logging
4386 They will fail (with an explanation) if you try to use them before logging
4387 has been started.
4387 has been started.
4388 \layout Subsection
4388 \layout Subsection
4389
4389
4390
4390
4391 \begin_inset LatexCommand \label{sub:System-shell-access}
4391 \begin_inset LatexCommand \label{sub:System-shell-access}
4392
4392
4393 \end_inset
4393 \end_inset
4394
4394
4395 System shell access
4395 System shell access
4396 \layout Standard
4396 \layout Standard
4397
4397
4398 Any input line beginning with a
4398 Any input line beginning with a
4399 \family typewriter
4399 \family typewriter
4400 !
4400 !
4401 \family default
4401 \family default
4402 character is passed verbatim (minus the
4402 character is passed verbatim (minus the
4403 \family typewriter
4403 \family typewriter
4404 !
4404 !
4405 \family default
4405 \family default
4406 , of course) to the underlying operating system.
4406 , of course) to the underlying operating system.
4407 For example, typing
4407 For example, typing
4408 \family typewriter
4408 \family typewriter
4409 !ls
4409 !ls
4410 \family default
4410 \family default
4411 will run
4411 will run
4412 \family typewriter
4412 \family typewriter
4413 'ls'
4413 'ls'
4414 \family default
4414 \family default
4415 in the current directory.
4415 in the current directory.
4416 \layout Subsubsection
4416 \layout Subsubsection
4417
4417
4418 Manual capture of command output
4418 Manual capture of command output
4419 \layout Standard
4419 \layout Standard
4420
4420
4421 If the input line begins with
4421 If the input line begins with
4422 \emph on
4422 \emph on
4423 two
4423 two
4424 \emph default
4424 \emph default
4425 exclamation marks,
4425 exclamation marks,
4426 \family typewriter
4426 \family typewriter
4427 !!
4427 !!
4428 \family default
4428 \family default
4429 , the command is executed but its output is captured and returned as a python
4429 , the command is executed but its output is captured and returned as a python
4430 list, split on newlines.
4430 list, split on newlines.
4431 Any output sent by the subprocess to standard error is printed separately,
4431 Any output sent by the subprocess to standard error is printed separately,
4432 so that the resulting list only captures standard output.
4432 so that the resulting list only captures standard output.
4433 The
4433 The
4434 \family typewriter
4434 \family typewriter
4435 !!
4435 !!
4436 \family default
4436 \family default
4437 syntax is a shorthand for the
4437 syntax is a shorthand for the
4438 \family typewriter
4438 \family typewriter
4439 %sx
4439 %sx
4440 \family default
4440 \family default
4441 magic command.
4441 magic command.
4442 \layout Standard
4442 \layout Standard
4443
4443
4444 Finally, the
4444 Finally, the
4445 \family typewriter
4445 \family typewriter
4446 %sc
4446 %sc
4447 \family default
4447 \family default
4448 magic (short for `shell capture') is similar to
4448 magic (short for `shell capture') is similar to
4449 \family typewriter
4449 \family typewriter
4450 %sx
4450 %sx
4451 \family default
4451 \family default
4452 , but allowing more fine-grained control of the capture details, and storing
4452 , but allowing more fine-grained control of the capture details, and storing
4453 the result directly into a named variable.
4453 the result directly into a named variable.
4454 \layout Standard
4454 \layout Standard
4455
4455
4456 See Sec.\SpecialChar ~
4456 See Sec.\SpecialChar ~
4457
4457
4458 \begin_inset LatexCommand \ref{sec:magic}
4458 \begin_inset LatexCommand \ref{sec:magic}
4459
4459
4460 \end_inset
4460 \end_inset
4461
4461
4462 for details on the magics
4462 for details on the magics
4463 \family typewriter
4463 \family typewriter
4464 %sc
4464 %sc
4465 \family default
4465 \family default
4466 and
4466 and
4467 \family typewriter
4467 \family typewriter
4468 %sx
4468 %sx
4469 \family default
4469 \family default
4470 , or use IPython's own help (
4470 , or use IPython's own help (
4471 \family typewriter
4471 \family typewriter
4472 sc?
4472 sc?
4473 \family default
4473 \family default
4474 and
4474 and
4475 \family typewriter
4475 \family typewriter
4476 sx?
4476 sx?
4477 \family default
4477 \family default
4478 ) for further details.
4478 ) for further details.
4479 \layout Standard
4479 \layout Standard
4480
4480
4481 IPython also allows you to expand the value of python variables when making
4481 IPython also allows you to expand the value of python variables when making
4482 system calls.
4482 system calls.
4483 Any python variable or expression which you prepend with
4483 Any python variable or expression which you prepend with
4484 \family typewriter
4484 \family typewriter
4485 $
4485 $
4486 \family default
4486 \family default
4487 will get expanded before the system call is made.
4487 will get expanded before the system call is made.
4488
4488
4489 \layout Standard
4489 \layout Standard
4490
4490
4491
4491
4492 \family typewriter
4492 \family typewriter
4493 In [1]: pyvar='Hello world'
4493 In [1]: pyvar='Hello world'
4494 \newline
4494 \newline
4495 In [2]: !echo "A python variable: $pyvar"
4495 In [2]: !echo "A python variable: $pyvar"
4496 \newline
4496 \newline
4497 A python variable: Hello world
4497 A python variable: Hello world
4498 \layout Standard
4498 \layout Standard
4499
4499
4500 If you want the shell to actually see a literal
4500 If you want the shell to actually see a literal
4501 \family typewriter
4501 \family typewriter
4502 $
4502 $
4503 \family default
4503 \family default
4504 , you need to type it twice:
4504 , you need to type it twice:
4505 \layout Standard
4505 \layout Standard
4506
4506
4507
4507
4508 \family typewriter
4508 \family typewriter
4509 In [3]: !echo "A system variable: $$HOME"
4509 In [3]: !echo "A system variable: $$HOME"
4510 \newline
4510 \newline
4511 A system variable: /home/fperez
4511 A system variable: /home/fperez
4512 \layout Standard
4512 \layout Standard
4513
4513
4514 You can pass arbitrary expressions, though you'll need to delimit them with
4514 You can pass arbitrary expressions, though you'll need to delimit them with
4515
4515
4516 \family typewriter
4516 \family typewriter
4517 {}
4517 {}
4518 \family default
4518 \family default
4519 if there is ambiguity as to the extent of the expression:
4519 if there is ambiguity as to the extent of the expression:
4520 \layout Standard
4520 \layout Standard
4521
4521
4522
4522
4523 \family typewriter
4523 \family typewriter
4524 In [5]: x=10
4524 In [5]: x=10
4525 \newline
4525 \newline
4526 In [6]: y=20
4526 In [6]: y=20
4527 \newline
4527 \newline
4528 In [13]: !echo $x+y
4528 In [13]: !echo $x+y
4529 \newline
4529 \newline
4530 10+y
4530 10+y
4531 \newline
4531 \newline
4532 In [7]: !echo ${x+y}
4532 In [7]: !echo ${x+y}
4533 \newline
4533 \newline
4534 30
4534 30
4535 \layout Standard
4535 \layout Standard
4536
4536
4537 Even object attributes can be expanded:
4537 Even object attributes can be expanded:
4538 \layout Standard
4538 \layout Standard
4539
4539
4540
4540
4541 \family typewriter
4541 \family typewriter
4542 In [12]: !echo $sys.argv
4542 In [12]: !echo $sys.argv
4543 \newline
4543 \newline
4544 [/home/fperez/usr/bin/ipython]
4544 [/home/fperez/usr/bin/ipython]
4545 \layout Subsection
4545 \layout Subsection
4546
4546
4547 System command aliases
4547 System command aliases
4548 \layout Standard
4548 \layout Standard
4549
4549
4550 The
4550 The
4551 \family typewriter
4551 \family typewriter
4552 %alias
4552 %alias
4553 \family default
4553 \family default
4554 magic function and the
4554 magic function and the
4555 \family typewriter
4555 \family typewriter
4556 alias
4556 alias
4557 \family default
4557 \family default
4558 option in the
4558 option in the
4559 \family typewriter
4559 \family typewriter
4560 ipythonrc
4560 ipythonrc
4561 \family default
4561 \family default
4562 configuration file allow you to define magic functions which are in fact
4562 configuration file allow you to define magic functions which are in fact
4563 system shell commands.
4563 system shell commands.
4564 These aliases can have parameters.
4564 These aliases can have parameters.
4565
4565
4566 \layout Standard
4566 \layout Standard
4567
4567
4568 '
4568 '
4569 \family typewriter
4569 \family typewriter
4570 %alias alias_name cmd
4570 %alias alias_name cmd
4571 \family default
4571 \family default
4572 ' defines '
4572 ' defines '
4573 \family typewriter
4573 \family typewriter
4574 alias_name
4574 alias_name
4575 \family default
4575 \family default
4576 ' as an alias for '
4576 ' as an alias for '
4577 \family typewriter
4577 \family typewriter
4578 cmd
4578 cmd
4579 \family default
4579 \family default
4580 '
4580 '
4581 \layout Standard
4581 \layout Standard
4582
4582
4583 Then, typing '
4583 Then, typing '
4584 \family typewriter
4584 \family typewriter
4585 %alias_name params
4585 %alias_name params
4586 \family default
4586 \family default
4587 ' will execute the system command '
4587 ' will execute the system command '
4588 \family typewriter
4588 \family typewriter
4589 cmd params
4589 cmd params
4590 \family default
4590 \family default
4591 ' (from your underlying operating system).
4591 ' (from your underlying operating system).
4592
4592
4593 \layout Standard
4593 \layout Standard
4594
4594
4595 You can also define aliases with parameters using
4595 You can also define aliases with parameters using
4596 \family typewriter
4596 \family typewriter
4597 %s
4597 %s
4598 \family default
4598 \family default
4599 specifiers (one per parameter).
4599 specifiers (one per parameter).
4600 The following example defines the
4600 The following example defines the
4601 \family typewriter
4601 \family typewriter
4602 %parts
4602 %parts
4603 \family default
4603 \family default
4604 function as an alias to the command '
4604 function as an alias to the command '
4605 \family typewriter
4605 \family typewriter
4606 echo first %s second %s
4606 echo first %s second %s
4607 \family default
4607 \family default
4608 ' where each
4608 ' where each
4609 \family typewriter
4609 \family typewriter
4610 %s
4610 %s
4611 \family default
4611 \family default
4612 will be replaced by a positional parameter to the call to
4612 will be replaced by a positional parameter to the call to
4613 \family typewriter
4613 \family typewriter
4614 %parts:
4614 %parts:
4615 \layout Standard
4615 \layout Standard
4616
4616
4617
4617
4618 \family typewriter
4618 \family typewriter
4619 In [1]: alias parts echo first %s second %s
4619 In [1]: alias parts echo first %s second %s
4620 \newline
4620 \newline
4621 In [2]: %parts A B
4621 In [2]: %parts A B
4622 \newline
4622 \newline
4623 first A second B
4623 first A second B
4624 \newline
4624 \newline
4625 In [3]: %parts A
4625 In [3]: %parts A
4626 \newline
4626 \newline
4627 Incorrect number of arguments: 2 expected.
4627 Incorrect number of arguments: 2 expected.
4628
4628
4629 \newline
4629 \newline
4630 parts is an alias to: 'echo first %s second %s'
4630 parts is an alias to: 'echo first %s second %s'
4631 \layout Standard
4631 \layout Standard
4632
4632
4633 If called with no parameters,
4633 If called with no parameters,
4634 \family typewriter
4634 \family typewriter
4635 %alias
4635 %alias
4636 \family default
4636 \family default
4637 prints the table of currently defined aliases.
4637 prints the table of currently defined aliases.
4638 \layout Standard
4638 \layout Standard
4639
4639
4640 The
4640 The
4641 \family typewriter
4641 \family typewriter
4642 %rehash/rehashx
4642 %rehash/rehashx
4643 \family default
4643 \family default
4644 magics allow you to load your entire
4644 magics allow you to load your entire
4645 \family typewriter
4645 \family typewriter
4646 $PATH
4646 $PATH
4647 \family default
4647 \family default
4648 as ipython aliases.
4648 as ipython aliases.
4649 See their respective docstrings (or sec.\SpecialChar ~
4649 See their respective docstrings (or sec.\SpecialChar ~
4650
4650
4651 \begin_inset LatexCommand \ref{sec:magic}
4651 \begin_inset LatexCommand \ref{sec:magic}
4652
4652
4653 \end_inset
4653 \end_inset
4654
4654
4655 for further details).
4655 for further details).
4656 \layout Subsection
4656 \layout Subsection
4657
4657
4658
4658
4659 \begin_inset LatexCommand \label{sec:dreload}
4659 \begin_inset LatexCommand \label{sec:dreload}
4660
4660
4661 \end_inset
4661 \end_inset
4662
4662
4663 Recursive reload
4663 Recursive reload
4664 \layout Standard
4664 \layout Standard
4665
4665
4666 The
4666 The
4667 \family typewriter
4667 \family typewriter
4668 %dreload
4668 %dreload
4669 \family default
4669 \family default
4670 command does a recursive reload of a module: changes made to the module
4670 command does a recursive reload of a module: changes made to the module
4671 since you imported will actually be available without having to exit.
4671 since you imported will actually be available without having to exit.
4672 \layout Subsection
4672 \layout Subsection
4673
4673
4674 Verbose and colored exception traceback printouts
4674 Verbose and colored exception traceback printouts
4675 \layout Standard
4675 \layout Standard
4676
4676
4677 IPython provides the option to see very detailed exception tracebacks, which
4677 IPython provides the option to see very detailed exception tracebacks, which
4678 can be especially useful when debugging large programs.
4678 can be especially useful when debugging large programs.
4679 You can run any Python file with the
4679 You can run any Python file with the
4680 \family typewriter
4680 \family typewriter
4681 %run
4681 %run
4682 \family default
4682 \family default
4683 function to benefit from these detailed tracebacks.
4683 function to benefit from these detailed tracebacks.
4684 Furthermore, both normal and verbose tracebacks can be colored (if your
4684 Furthermore, both normal and verbose tracebacks can be colored (if your
4685 terminal supports it) which makes them much easier to parse visually.
4685 terminal supports it) which makes them much easier to parse visually.
4686 \layout Standard
4686 \layout Standard
4687
4687
4688 See the magic
4688 See the magic
4689 \family typewriter
4689 \family typewriter
4690 xmode
4690 xmode
4691 \family default
4691 \family default
4692 and
4692 and
4693 \family typewriter
4693 \family typewriter
4694 colors
4694 colors
4695 \family default
4695 \family default
4696 functions for details (just type
4696 functions for details (just type
4697 \family typewriter
4697 \family typewriter
4698 %magic
4698 %magic
4699 \family default
4699 \family default
4700 ).
4700 ).
4701 \layout Standard
4701 \layout Standard
4702
4702
4703 These features are basically a terminal version of Ka-Ping Yee's
4703 These features are basically a terminal version of Ka-Ping Yee's
4704 \family typewriter
4704 \family typewriter
4705 cgitb
4705 cgitb
4706 \family default
4706 \family default
4707 module, now part of the standard Python library.
4707 module, now part of the standard Python library.
4708 \layout Subsection
4708 \layout Subsection
4709
4709
4710
4710
4711 \begin_inset LatexCommand \label{sec:cache_input}
4711 \begin_inset LatexCommand \label{sec:cache_input}
4712
4712
4713 \end_inset
4713 \end_inset
4714
4714
4715 Input caching system
4715 Input caching system
4716 \layout Standard
4716 \layout Standard
4717
4717
4718 IPython offers numbered prompts (In/Out) with input and output caching.
4718 IPython offers numbered prompts (In/Out) with input and output caching.
4719 All input is saved and can be retrieved as variables (besides the usual
4719 All input is saved and can be retrieved as variables (besides the usual
4720 arrow key recall).
4720 arrow key recall).
4721 \layout Standard
4721 \layout Standard
4722
4722
4723 The following GLOBAL variables always exist (so don't overwrite them!):
4723 The following GLOBAL variables always exist (so don't overwrite them!):
4724
4724
4725 \family typewriter
4725 \family typewriter
4726 _i
4726 _i
4727 \family default
4727 \family default
4728 : stores previous input.
4728 : stores previous input.
4729
4729
4730 \family typewriter
4730 \family typewriter
4731 _ii
4731 _ii
4732 \family default
4732 \family default
4733 : next previous.
4733 : next previous.
4734
4734
4735 \family typewriter
4735 \family typewriter
4736 _iii
4736 _iii
4737 \family default
4737 \family default
4738 : next-next previous.
4738 : next-next previous.
4739
4739
4740 \family typewriter
4740 \family typewriter
4741 _ih
4741 _ih
4742 \family default
4742 \family default
4743 : a list of all input
4743 : a list of all input
4744 \family typewriter
4744 \family typewriter
4745 _ih[n]
4745 _ih[n]
4746 \family default
4746 \family default
4747 is the input from line
4747 is the input from line
4748 \family typewriter
4748 \family typewriter
4749 n
4749 n
4750 \family default
4750 \family default
4751 and this list is aliased to the global variable
4751 and this list is aliased to the global variable
4752 \family typewriter
4752 \family typewriter
4753 In
4753 In
4754 \family default
4754 \family default
4755 .
4755 .
4756 If you overwrite
4756 If you overwrite
4757 \family typewriter
4757 \family typewriter
4758 In
4758 In
4759 \family default
4759 \family default
4760 with a variable of your own, you can remake the assignment to the internal
4760 with a variable of your own, you can remake the assignment to the internal
4761 list with a simple
4761 list with a simple
4762 \family typewriter
4762 \family typewriter
4763 'In=_ih'
4763 'In=_ih'
4764 \family default
4764 \family default
4765 .
4765 .
4766 \layout Standard
4766 \layout Standard
4767
4767
4768 Additionally, global variables named
4768 Additionally, global variables named
4769 \family typewriter
4769 \family typewriter
4770 _i<n>
4770 _i<n>
4771 \family default
4771 \family default
4772 are dynamically created (
4772 are dynamically created (
4773 \family typewriter
4773 \family typewriter
4774 <n>
4774 <n>
4775 \family default
4775 \family default
4776 being the prompt counter), such that
4776 being the prompt counter), such that
4777 \newline
4777 \newline
4778
4778
4779 \family typewriter
4779 \family typewriter
4780 _i<n> == _ih[<n>] == In[<n>].
4780 _i<n> == _ih[<n>] == In[<n>].
4781 \layout Standard
4781 \layout Standard
4782
4782
4783 For example, what you typed at prompt 14 is available as
4783 For example, what you typed at prompt 14 is available as
4784 \family typewriter
4784 \family typewriter
4785 _i14,
4785 _i14,
4786 \family default
4786 \family default
4787
4787
4788 \family typewriter
4788 \family typewriter
4789 _ih[14]
4789 _ih[14]
4790 \family default
4790 \family default
4791 and
4791 and
4792 \family typewriter
4792 \family typewriter
4793 In[14]
4793 In[14]
4794 \family default
4794 \family default
4795 .
4795 .
4796 \layout Standard
4796 \layout Standard
4797
4797
4798 This allows you to easily cut and paste multi line interactive prompts by
4798 This allows you to easily cut and paste multi line interactive prompts by
4799 printing them out: they print like a clean string, without prompt characters.
4799 printing them out: they print like a clean string, without prompt characters.
4800 You can also manipulate them like regular variables (they are strings),
4800 You can also manipulate them like regular variables (they are strings),
4801 modify or exec them (typing
4801 modify or exec them (typing
4802 \family typewriter
4802 \family typewriter
4803 'exec _i9'
4803 'exec _i9'
4804 \family default
4804 \family default
4805 will re-execute the contents of input prompt 9, '
4805 will re-execute the contents of input prompt 9, '
4806 \family typewriter
4806 \family typewriter
4807 exec In[9:14]+In[18]
4807 exec In[9:14]+In[18]
4808 \family default
4808 \family default
4809 ' will re-execute lines 9 through 13 and line 18).
4809 ' will re-execute lines 9 through 13 and line 18).
4810 \layout Standard
4810 \layout Standard
4811
4811
4812 You can also re-execute multiple lines of input easily by using the magic
4812 You can also re-execute multiple lines of input easily by using the magic
4813
4813
4814 \family typewriter
4814 \family typewriter
4815 %macro
4815 %macro
4816 \family default
4816 \family default
4817 function (which automates the process and allows re-execution without having
4817 function (which automates the process and allows re-execution without having
4818 to type '
4818 to type '
4819 \family typewriter
4819 \family typewriter
4820 exec
4820 exec
4821 \family default
4821 \family default
4822 ' every time).
4822 ' every time).
4823 The macro system also allows you to re-execute previous lines which include
4823 The macro system also allows you to re-execute previous lines which include
4824 magic function calls (which require special processing).
4824 magic function calls (which require special processing).
4825 Type
4825 Type
4826 \family typewriter
4826 \family typewriter
4827 %macro?
4827 %macro?
4828 \family default
4828 \family default
4829 or see sec.
4829 or see sec.
4830
4830
4831 \begin_inset LatexCommand \ref{sec:magic}
4831 \begin_inset LatexCommand \ref{sec:magic}
4832
4832
4833 \end_inset
4833 \end_inset
4834
4834
4835 for more details on the macro system.
4835 for more details on the macro system.
4836 \layout Standard
4836 \layout Standard
4837
4837
4838 A history function
4838 A history function
4839 \family typewriter
4839 \family typewriter
4840 %hist
4840 %hist
4841 \family default
4841 \family default
4842 allows you to see any part of your input history by printing a range of
4842 allows you to see any part of your input history by printing a range of
4843 the
4843 the
4844 \family typewriter
4844 \family typewriter
4845 _i
4845 _i
4846 \family default
4846 \family default
4847 variables.
4847 variables.
4848 \layout Subsection
4848 \layout Subsection
4849
4849
4850
4850
4851 \begin_inset LatexCommand \label{sec:cache_output}
4851 \begin_inset LatexCommand \label{sec:cache_output}
4852
4852
4853 \end_inset
4853 \end_inset
4854
4854
4855 Output caching system
4855 Output caching system
4856 \layout Standard
4856 \layout Standard
4857
4857
4858 For output that is returned from actions, a system similar to the input
4858 For output that is returned from actions, a system similar to the input
4859 cache exists but using
4859 cache exists but using
4860 \family typewriter
4860 \family typewriter
4861 _
4861 _
4862 \family default
4862 \family default
4863 instead of
4863 instead of
4864 \family typewriter
4864 \family typewriter
4865 _i
4865 _i
4866 \family default
4866 \family default
4867 .
4867 .
4868 Only actions that produce a result (NOT assignments, for example) are cached.
4868 Only actions that produce a result (NOT assignments, for example) are cached.
4869 If you are familiar with Mathematica, IPython's
4869 If you are familiar with Mathematica, IPython's
4870 \family typewriter
4870 \family typewriter
4871 _
4871 _
4872 \family default
4872 \family default
4873 variables behave exactly like Mathematica's
4873 variables behave exactly like Mathematica's
4874 \family typewriter
4874 \family typewriter
4875 %
4875 %
4876 \family default
4876 \family default
4877 variables.
4877 variables.
4878 \layout Standard
4878 \layout Standard
4879
4879
4880 The following GLOBAL variables always exist (so don't overwrite them!):
4880 The following GLOBAL variables always exist (so don't overwrite them!):
4881
4881
4882 \layout List
4882 \layout List
4883 \labelwidthstring 00.00.0000
4883 \labelwidthstring 00.00.0000
4884
4884
4885
4885
4886 \family typewriter
4886 \family typewriter
4887 \series bold
4887 \series bold
4888 _
4888 _
4889 \family default
4889 \family default
4890 \series default
4890 \series default
4891 (a
4891 (a
4892 \emph on
4892 \emph on
4893 single
4893 single
4894 \emph default
4894 \emph default
4895 underscore) : stores previous output, like Python's default interpreter.
4895 underscore) : stores previous output, like Python's default interpreter.
4896 \layout List
4896 \layout List
4897 \labelwidthstring 00.00.0000
4897 \labelwidthstring 00.00.0000
4898
4898
4899
4899
4900 \family typewriter
4900 \family typewriter
4901 \series bold
4901 \series bold
4902 __
4902 __
4903 \family default
4903 \family default
4904 \series default
4904 \series default
4905 (two underscores): next previous.
4905 (two underscores): next previous.
4906 \layout List
4906 \layout List
4907 \labelwidthstring 00.00.0000
4907 \labelwidthstring 00.00.0000
4908
4908
4909
4909
4910 \family typewriter
4910 \family typewriter
4911 \series bold
4911 \series bold
4912 ___
4912 ___
4913 \family default
4913 \family default
4914 \series default
4914 \series default
4915 (three underscores): next-next previous.
4915 (three underscores): next-next previous.
4916 \layout Standard
4916 \layout Standard
4917
4917
4918 Additionally, global variables named
4918 Additionally, global variables named
4919 \family typewriter
4919 \family typewriter
4920 _<n>
4920 _<n>
4921 \family default
4921 \family default
4922 are dynamically created (
4922 are dynamically created (
4923 \family typewriter
4923 \family typewriter
4924 <n>
4924 <n>
4925 \family default
4925 \family default
4926 being the prompt counter), such that the result of output
4926 being the prompt counter), such that the result of output
4927 \family typewriter
4927 \family typewriter
4928 <n>
4928 <n>
4929 \family default
4929 \family default
4930 is always available as
4930 is always available as
4931 \family typewriter
4931 \family typewriter
4932 _<n>
4932 _<n>
4933 \family default
4933 \family default
4934 (don't use the angle brackets, just the number, e.g.
4934 (don't use the angle brackets, just the number, e.g.
4935
4935
4936 \family typewriter
4936 \family typewriter
4937 _21
4937 _21
4938 \family default
4938 \family default
4939 ).
4939 ).
4940 \layout Standard
4940 \layout Standard
4941
4941
4942 These global variables are all stored in a global dictionary (not a list,
4942 These global variables are all stored in a global dictionary (not a list,
4943 since it only has entries for lines which returned a result) available
4943 since it only has entries for lines which returned a result) available
4944 under the names
4944 under the names
4945 \family typewriter
4945 \family typewriter
4946 _oh
4946 _oh
4947 \family default
4947 \family default
4948 and
4948 and
4949 \family typewriter
4949 \family typewriter
4950 Out
4950 Out
4951 \family default
4951 \family default
4952 (similar to
4952 (similar to
4953 \family typewriter
4953 \family typewriter
4954 _ih
4954 _ih
4955 \family default
4955 \family default
4956 and
4956 and
4957 \family typewriter
4957 \family typewriter
4958 In
4958 In
4959 \family default
4959 \family default
4960 ).
4960 ).
4961 So the output from line 12 can be obtained as
4961 So the output from line 12 can be obtained as
4962 \family typewriter
4962 \family typewriter
4963 _12
4963 _12
4964 \family default
4964 \family default
4965 ,
4965 ,
4966 \family typewriter
4966 \family typewriter
4967 Out[12]
4967 Out[12]
4968 \family default
4968 \family default
4969 or
4969 or
4970 \family typewriter
4970 \family typewriter
4971 _oh[12]
4971 _oh[12]
4972 \family default
4972 \family default
4973 .
4973 .
4974 If you accidentally overwrite the
4974 If you accidentally overwrite the
4975 \family typewriter
4975 \family typewriter
4976 Out
4976 Out
4977 \family default
4977 \family default
4978 variable you can recover it by typing
4978 variable you can recover it by typing
4979 \family typewriter
4979 \family typewriter
4980 'Out=_oh
4980 'Out=_oh
4981 \family default
4981 \family default
4982 ' at the prompt.
4982 ' at the prompt.
4983 \layout Standard
4983 \layout Standard
4984
4984
4985 This system obviously can potentially put heavy memory demands on your system,
4985 This system obviously can potentially put heavy memory demands on your system,
4986 since it prevents Python's garbage collector from removing any previously
4986 since it prevents Python's garbage collector from removing any previously
4987 computed results.
4987 computed results.
4988 You can control how many results are kept in memory with the option (at
4988 You can control how many results are kept in memory with the option (at
4989 the command line or in your
4989 the command line or in your
4990 \family typewriter
4990 \family typewriter
4991 ipythonrc
4991 ipythonrc
4992 \family default
4992 \family default
4993 file)
4993 file)
4994 \family typewriter
4994 \family typewriter
4995 cache_size
4995 cache_size
4996 \family default
4996 \family default
4997 .
4997 .
4998 If you set it to 0, the whole system is completely disabled and the prompts
4998 If you set it to 0, the whole system is completely disabled and the prompts
4999 revert to the classic
4999 revert to the classic
5000 \family typewriter
5000 \family typewriter
5001 '>>>'
5001 '>>>'
5002 \family default
5002 \family default
5003 of normal Python.
5003 of normal Python.
5004 \layout Subsection
5004 \layout Subsection
5005
5005
5006 Directory history
5006 Directory history
5007 \layout Standard
5007 \layout Standard
5008
5008
5009 Your history of visited directories is kept in the global list
5009 Your history of visited directories is kept in the global list
5010 \family typewriter
5010 \family typewriter
5011 _dh
5011 _dh
5012 \family default
5012 \family default
5013 , and the magic
5013 , and the magic
5014 \family typewriter
5014 \family typewriter
5015 %cd
5015 %cd
5016 \family default
5016 \family default
5017 command can be used to go to any entry in that list.
5017 command can be used to go to any entry in that list.
5018 The
5018 The
5019 \family typewriter
5019 \family typewriter
5020 %dhist
5020 %dhist
5021 \family default
5021 \family default
5022 command allows you to view this history.
5022 command allows you to view this history.
5023 \layout Subsection
5023 \layout Subsection
5024
5024
5025 Automatic parentheses and quotes
5025 Automatic parentheses and quotes
5026 \layout Standard
5026 \layout Standard
5027
5027
5028 These features were adapted from Nathan Gray's LazyPython.
5028 These features were adapted from Nathan Gray's LazyPython.
5029 They are meant to allow less typing for common situations.
5029 They are meant to allow less typing for common situations.
5030 \layout Subsubsection
5030 \layout Subsubsection
5031
5031
5032 Automatic parentheses
5032 Automatic parentheses
5033 \layout Standard
5033 \layout Standard
5034
5034
5035 Callable objects (i.e.
5035 Callable objects (i.e.
5036 functions, methods, etc) can be invoked like this (notice the commas between
5036 functions, methods, etc) can be invoked like this (notice the commas between
5037 the arguments):
5037 the arguments):
5038 \layout Standard
5038 \layout Standard
5039
5039
5040
5040
5041 \family typewriter
5041 \family typewriter
5042 >>> callable_ob arg1, arg2, arg3
5042 >>> callable_ob arg1, arg2, arg3
5043 \layout Standard
5043 \layout Standard
5044
5044
5045 and the input will be translated to this:
5045 and the input will be translated to this:
5046 \layout Standard
5046 \layout Standard
5047
5047
5048
5048
5049 \family typewriter
5049 \family typewriter
5050 --> callable_ob(arg1, arg2, arg3)
5050 --> callable_ob(arg1, arg2, arg3)
5051 \layout Standard
5051 \layout Standard
5052
5052
5053 You can force automatic parentheses by using '/' as the first character
5053 You can force automatic parentheses by using '/' as the first character
5054 of a line.
5054 of a line.
5055 For example:
5055 For example:
5056 \layout Standard
5056 \layout Standard
5057
5057
5058
5058
5059 \family typewriter
5059 \family typewriter
5060 >>> /globals # becomes 'globals()'
5060 >>> /globals # becomes 'globals()'
5061 \layout Standard
5061 \layout Standard
5062
5062
5063 Note that the '/' MUST be the first character on the line! This won't work:
5063 Note that the '/' MUST be the first character on the line! This won't work:
5064
5064
5065 \layout Standard
5065 \layout Standard
5066
5066
5067
5067
5068 \family typewriter
5068 \family typewriter
5069 >>> print /globals # syntax error
5069 >>> print /globals # syntax error
5070 \layout Standard
5070 \layout Standard
5071
5071
5072 In most cases the automatic algorithm should work, so you should rarely
5072 In most cases the automatic algorithm should work, so you should rarely
5073 need to explicitly invoke /.
5073 need to explicitly invoke /.
5074 One notable exception is if you are trying to call a function with a list
5074 One notable exception is if you are trying to call a function with a list
5075 of tuples as arguments (the parenthesis will confuse IPython):
5075 of tuples as arguments (the parenthesis will confuse IPython):
5076 \layout Standard
5076 \layout Standard
5077
5077
5078
5078
5079 \family typewriter
5079 \family typewriter
5080 In [1]: zip (1,2,3),(4,5,6) # won't work
5080 In [1]: zip (1,2,3),(4,5,6) # won't work
5081 \layout Standard
5081 \layout Standard
5082
5082
5083 but this will work:
5083 but this will work:
5084 \layout Standard
5084 \layout Standard
5085
5085
5086
5086
5087 \family typewriter
5087 \family typewriter
5088 In [2]: /zip (1,2,3),(4,5,6)
5088 In [2]: /zip (1,2,3),(4,5,6)
5089 \newline
5089 \newline
5090 ------> zip ((1,2,3),(4,5,6))
5090 ------> zip ((1,2,3),(4,5,6))
5091 \newline
5091 \newline
5092 Out[2]= [(1, 4), (2, 5), (3, 6)]
5092 Out[2]= [(1, 4), (2, 5), (3, 6)]
5093 \layout Standard
5093 \layout Standard
5094
5094
5095 IPython tells you that it has altered your command line by displaying the
5095 IPython tells you that it has altered your command line by displaying the
5096 new command line preceded by
5096 new command line preceded by
5097 \family typewriter
5097 \family typewriter
5098 -->
5098 -->
5099 \family default
5099 \family default
5100 .
5100 .
5101 e.g.:
5101 e.g.:
5102 \layout Standard
5102 \layout Standard
5103
5103
5104
5104
5105 \family typewriter
5105 \family typewriter
5106 In [18]: callable list
5106 In [18]: callable list
5107 \newline
5107 \newline
5108 -------> callable (list)
5108 -------> callable (list)
5109 \layout Subsubsection
5109 \layout Subsubsection
5110
5110
5111 Automatic quoting
5111 Automatic quoting
5112 \layout Standard
5112 \layout Standard
5113
5113
5114 You can force automatic quoting of a function's arguments by using
5114 You can force automatic quoting of a function's arguments by using
5115 \family typewriter
5115 \family typewriter
5116 `,'
5116 `,'
5117 \family default
5117 \family default
5118 or
5118 or
5119 \family typewriter
5119 \family typewriter
5120 `;'
5120 `;'
5121 \family default
5121 \family default
5122 as the first character of a line.
5122 as the first character of a line.
5123 For example:
5123 For example:
5124 \layout Standard
5124 \layout Standard
5125
5125
5126
5126
5127 \family typewriter
5127 \family typewriter
5128 >>> ,my_function /home/me # becomes my_function("/home/me")
5128 >>> ,my_function /home/me # becomes my_function("/home/me")
5129 \layout Standard
5129 \layout Standard
5130
5130
5131 If you use
5131 If you use
5132 \family typewriter
5132 \family typewriter
5133 `;'
5133 `;'
5134 \family default
5134 \family default
5135 instead, the whole argument is quoted as a single string (while
5135 instead, the whole argument is quoted as a single string (while
5136 \family typewriter
5136 \family typewriter
5137 `,'
5137 `,'
5138 \family default
5138 \family default
5139 splits on whitespace):
5139 splits on whitespace):
5140 \layout Standard
5140 \layout Standard
5141
5141
5142
5142
5143 \family typewriter
5143 \family typewriter
5144 >>> ,my_function a b c # becomes my_function("a","b","c")
5144 >>> ,my_function a b c # becomes my_function("a","b","c")
5145 \layout Standard
5145 \layout Standard
5146
5146
5147
5147
5148 \family typewriter
5148 \family typewriter
5149 >>> ;my_function a b c # becomes my_function("a b c")
5149 >>> ;my_function a b c # becomes my_function("a b c")
5150 \layout Standard
5150 \layout Standard
5151
5151
5152 Note that the `
5152 Note that the `
5153 \family typewriter
5153 \family typewriter
5154 ,
5154 ,
5155 \family default
5155 \family default
5156 ' or `
5156 ' or `
5157 \family typewriter
5157 \family typewriter
5158 ;
5158 ;
5159 \family default
5159 \family default
5160 ' MUST be the first character on the line! This won't work:
5160 ' MUST be the first character on the line! This won't work:
5161 \layout Standard
5161 \layout Standard
5162
5162
5163
5163
5164 \family typewriter
5164 \family typewriter
5165 >>> x = ,my_function /home/me # syntax error
5165 >>> x = ,my_function /home/me # syntax error
5166 \layout Section
5166 \layout Section
5167
5167
5168
5168
5169 \begin_inset LatexCommand \label{sec:customization}
5169 \begin_inset LatexCommand \label{sec:customization}
5170
5170
5171 \end_inset
5171 \end_inset
5172
5172
5173 Customization
5173 Customization
5174 \layout Standard
5174 \layout Standard
5175
5175
5176 As we've already mentioned, IPython reads a configuration file which can
5176 As we've already mentioned, IPython reads a configuration file which can
5177 be specified at the command line (
5177 be specified at the command line (
5178 \family typewriter
5178 \family typewriter
5179 -rcfile
5179 -rcfile
5180 \family default
5180 \family default
5181 ) or which by default is assumed to be called
5181 ) or which by default is assumed to be called
5182 \family typewriter
5182 \family typewriter
5183 ipythonrc
5183 ipythonrc
5184 \family default
5184 \family default
5185 .
5185 .
5186 Such a file is looked for in the current directory where IPython is started
5186 Such a file is looked for in the current directory where IPython is started
5187 and then in your
5187 and then in your
5188 \family typewriter
5188 \family typewriter
5189 IPYTHONDIR
5189 IPYTHONDIR
5190 \family default
5190 \family default
5191 , which allows you to have local configuration files for specific projects.
5191 , which allows you to have local configuration files for specific projects.
5192 In this section we will call these types of configuration files simply
5192 In this section we will call these types of configuration files simply
5193 rcfiles (short for resource configuration file).
5193 rcfiles (short for resource configuration file).
5194 \layout Standard
5194 \layout Standard
5195
5195
5196 The syntax of an rcfile is one of key-value pairs separated by whitespace,
5196 The syntax of an rcfile is one of key-value pairs separated by whitespace,
5197 one per line.
5197 one per line.
5198 Lines beginning with a
5198 Lines beginning with a
5199 \family typewriter
5199 \family typewriter
5200 #
5200 #
5201 \family default
5201 \family default
5202 are ignored as comments, but comments can
5202 are ignored as comments, but comments can
5203 \series bold
5203 \series bold
5204 not
5204 not
5205 \series default
5205 \series default
5206 be put on lines with data (the parser is fairly primitive).
5206 be put on lines with data (the parser is fairly primitive).
5207 Note that these are not python files, and this is deliberate, because it
5207 Note that these are not python files, and this is deliberate, because it
5208 allows us to do some things which would be quite tricky to implement if
5208 allows us to do some things which would be quite tricky to implement if
5209 they were normal python files.
5209 they were normal python files.
5210 \layout Standard
5210 \layout Standard
5211
5211
5212 First, an rcfile can contain permanent default values for almost all command
5212 First, an rcfile can contain permanent default values for almost all command
5213 line options (except things like
5213 line options (except things like
5214 \family typewriter
5214 \family typewriter
5215 -help
5215 -help
5216 \family default
5216 \family default
5217 or
5217 or
5218 \family typewriter
5218 \family typewriter
5219 -Version
5219 -Version
5220 \family default
5220 \family default
5221 ).
5221 ).
5222 Sec\SpecialChar ~
5222 Sec\SpecialChar ~
5223
5223
5224 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
5224 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
5225
5225
5226 \end_inset
5226 \end_inset
5227
5227
5228 contains a description of all command-line options.
5228 contains a description of all command-line options.
5229 However, values you explicitly specify at the command line override the
5229 However, values you explicitly specify at the command line override the
5230 values defined in the rcfile.
5230 values defined in the rcfile.
5231 \layout Standard
5231 \layout Standard
5232
5232
5233 Besides command line option values, the rcfile can specify values for certain
5233 Besides command line option values, the rcfile can specify values for certain
5234 extra special options which are not available at the command line.
5234 extra special options which are not available at the command line.
5235 These options are briefly described below.
5235 These options are briefly described below.
5236
5236
5237 \layout Standard
5237 \layout Standard
5238
5238
5239 Each of these options may appear as many times as you need it in the file.
5239 Each of these options may appear as many times as you need it in the file.
5240 \layout List
5240 \layout List
5241 \labelwidthstring 00.00.0000
5241 \labelwidthstring 00.00.0000
5242
5242
5243
5243
5244 \family typewriter
5244 \family typewriter
5245 \series bold
5245 \series bold
5246 include\SpecialChar ~
5246 include\SpecialChar ~
5247 <file1>\SpecialChar ~
5247 <file1>\SpecialChar ~
5248 <file2>\SpecialChar ~
5248 <file2>\SpecialChar ~
5249 ...
5249 ...
5250 \family default
5250 \family default
5251 \series default
5251 \series default
5252 : you can name
5252 : you can name
5253 \emph on
5253 \emph on
5254 other
5254 other
5255 \emph default
5255 \emph default
5256 rcfiles you want to recursively load up to 15 levels (don't use the
5256 rcfiles you want to recursively load up to 15 levels (don't use the
5257 \family typewriter
5257 \family typewriter
5258 <>
5258 <>
5259 \family default
5259 \family default
5260 brackets in your names!).
5260 brackets in your names!).
5261 This feature allows you to define a 'base' rcfile with general options
5261 This feature allows you to define a 'base' rcfile with general options
5262 and special-purpose files which can be loaded only when needed with particular
5262 and special-purpose files which can be loaded only when needed with particular
5263 configuration options.
5263 configuration options.
5264 To make this more convenient, IPython accepts the
5264 To make this more convenient, IPython accepts the
5265 \family typewriter
5265 \family typewriter
5266 -profile <name>
5266 -profile <name>
5267 \family default
5267 \family default
5268 option (abbreviates to
5268 option (abbreviates to
5269 \family typewriter
5269 \family typewriter
5270 -p <name
5270 -p <name
5271 \family default
5271 \family default
5272 >)
5272 >)
5273 \family typewriter
5273 \family typewriter
5274 which
5274 which
5275 \family default
5275 \family default
5276 tells it to look for an rcfile named
5276 tells it to look for an rcfile named
5277 \family typewriter
5277 \family typewriter
5278 ipythonrc-<name>
5278 ipythonrc-<name>
5279 \family default
5279 \family default
5280 .
5280 .
5281
5281
5282 \layout List
5282 \layout List
5283 \labelwidthstring 00.00.0000
5283 \labelwidthstring 00.00.0000
5284
5284
5285
5285
5286 \family typewriter
5286 \family typewriter
5287 \series bold
5287 \series bold
5288 import_mod\SpecialChar ~
5288 import_mod\SpecialChar ~
5289 <mod1>\SpecialChar ~
5289 <mod1>\SpecialChar ~
5290 <mod2>\SpecialChar ~
5290 <mod2>\SpecialChar ~
5291 ...
5291 ...
5292 \family default
5292 \family default
5293 \series default
5293 \series default
5294 : import modules with '
5294 : import modules with '
5295 \family typewriter
5295 \family typewriter
5296 import
5296 import
5297 \family default
5297 \family default
5298
5298
5299 \family typewriter
5299 \family typewriter
5300 <mod1>,<mod2>,...
5300 <mod1>,<mod2>,...
5301 \family default
5301 \family default
5302 '
5302 '
5303 \layout List
5303 \layout List
5304 \labelwidthstring 00.00.0000
5304 \labelwidthstring 00.00.0000
5305
5305
5306
5306
5307 \family typewriter
5307 \family typewriter
5308 \series bold
5308 \series bold
5309 import_some\SpecialChar ~
5309 import_some\SpecialChar ~
5310 <mod>\SpecialChar ~
5310 <mod>\SpecialChar ~
5311 <f1>\SpecialChar ~
5311 <f1>\SpecialChar ~
5312 <f2>\SpecialChar ~
5312 <f2>\SpecialChar ~
5313 ...
5313 ...
5314 \family default
5314 \family default
5315 \series default
5315 \series default
5316 : import functions with '
5316 : import functions with '
5317 \family typewriter
5317 \family typewriter
5318 from <mod> import
5318 from <mod> import
5319 \family default
5319 \family default
5320
5320
5321 \family typewriter
5321 \family typewriter
5322 <f1>,<f2>,...
5322 <f1>,<f2>,...
5323 \family default
5323 \family default
5324 '
5324 '
5325 \layout List
5325 \layout List
5326 \labelwidthstring 00.00.0000
5326 \labelwidthstring 00.00.0000
5327
5327
5328
5328
5329 \family typewriter
5329 \family typewriter
5330 \series bold
5330 \series bold
5331 import_all\SpecialChar ~
5331 import_all\SpecialChar ~
5332 <mod1>\SpecialChar ~
5332 <mod1>\SpecialChar ~
5333 <mod2>\SpecialChar ~
5333 <mod2>\SpecialChar ~
5334 ...
5334 ...
5335 \family default
5335 \family default
5336 \series default
5336 \series default
5337 : for each module listed import functions with '
5337 : for each module listed import functions with '
5338 \family typewriter
5338 \family typewriter
5339 from <mod> import *
5339 from <mod> import *
5340 \family default
5340 \family default
5341 '
5341 '
5342 \layout List
5342 \layout List
5343 \labelwidthstring 00.00.0000
5343 \labelwidthstring 00.00.0000
5344
5344
5345
5345
5346 \family typewriter
5346 \family typewriter
5347 \series bold
5347 \series bold
5348 execute\SpecialChar ~
5348 execute\SpecialChar ~
5349 <python\SpecialChar ~
5349 <python\SpecialChar ~
5350 code>
5350 code>
5351 \family default
5351 \family default
5352 \series default
5352 \series default
5353 : give any single-line python code to be executed.
5353 : give any single-line python code to be executed.
5354 \layout List
5354 \layout List
5355 \labelwidthstring 00.00.0000
5355 \labelwidthstring 00.00.0000
5356
5356
5357
5357
5358 \family typewriter
5358 \family typewriter
5359 \series bold
5359 \series bold
5360 execfile\SpecialChar ~
5360 execfile\SpecialChar ~
5361 <filename>
5361 <filename>
5362 \family default
5362 \family default
5363 \series default
5363 \series default
5364 : execute the python file given with an '
5364 : execute the python file given with an '
5365 \family typewriter
5365 \family typewriter
5366 execfile(filename)
5366 execfile(filename)
5367 \family default
5367 \family default
5368 ' command.
5368 ' command.
5369 Username expansion is performed on the given names.
5369 Username expansion is performed on the given names.
5370 So if you need any amount of extra fancy customization that won't fit in
5370 So if you need any amount of extra fancy customization that won't fit in
5371 any of the above 'canned' options, you can just put it in a separate python
5371 any of the above 'canned' options, you can just put it in a separate python
5372 file and execute it.
5372 file and execute it.
5373 \layout List
5373 \layout List
5374 \labelwidthstring 00.00.0000
5374 \labelwidthstring 00.00.0000
5375
5375
5376
5376
5377 \family typewriter
5377 \family typewriter
5378 \series bold
5378 \series bold
5379 alias\SpecialChar ~
5379 alias\SpecialChar ~
5380 <alias_def>
5380 <alias_def>
5381 \family default
5381 \family default
5382 \series default
5382 \series default
5383 : this is equivalent to calling '
5383 : this is equivalent to calling '
5384 \family typewriter
5384 \family typewriter
5385 %alias\SpecialChar ~
5385 %alias\SpecialChar ~
5386 <alias_def>
5386 <alias_def>
5387 \family default
5387 \family default
5388 ' at the IPython command line.
5388 ' at the IPython command line.
5389 This way, from within IPython you can do common system tasks without having
5389 This way, from within IPython you can do common system tasks without having
5390 to exit it or use the
5390 to exit it or use the
5391 \family typewriter
5391 \family typewriter
5392 !
5392 !
5393 \family default
5393 \family default
5394 escape.
5394 escape.
5395 IPython isn't meant to be a shell replacement, but it is often very useful
5395 IPython isn't meant to be a shell replacement, but it is often very useful
5396 to be able to do things with files while testing code.
5396 to be able to do things with files while testing code.
5397 This gives you the flexibility to have within IPython any aliases you may
5397 This gives you the flexibility to have within IPython any aliases you may
5398 be used to under your normal system shell.
5398 be used to under your normal system shell.
5399 \layout Subsection
5399 \layout Subsection
5400
5400
5401
5401
5402 \begin_inset LatexCommand \label{sec:ipytonrc-sample}
5402 \begin_inset LatexCommand \label{sec:ipytonrc-sample}
5403
5403
5404 \end_inset
5404 \end_inset
5405
5405
5406 Sample
5406 Sample
5407 \family typewriter
5407 \family typewriter
5408 ipythonrc
5408 ipythonrc
5409 \family default
5409 \family default
5410 file
5410 file
5411 \layout Standard
5411 \layout Standard
5412
5412
5413 The default rcfile, called
5413 The default rcfile, called
5414 \family typewriter
5414 \family typewriter
5415 ipythonrc
5415 ipythonrc
5416 \family default
5416 \family default
5417 and supplied in your
5417 and supplied in your
5418 \family typewriter
5418 \family typewriter
5419 IPYTHONDIR
5419 IPYTHONDIR
5420 \family default
5420 \family default
5421 directory contains lots of comments on all of these options.
5421 directory contains lots of comments on all of these options.
5422 We reproduce it here for reference:
5422 We reproduce it here for reference:
5423 \layout Standard
5423 \layout Standard
5424
5424
5425
5425
5426 \begin_inset ERT
5426 \begin_inset ERT
5427 status Open
5427 status Open
5428
5428
5429 \layout Standard
5429 \layout Standard
5430
5430
5431 \backslash
5431 \backslash
5432 codelist{../IPython/UserConfig/ipythonrc}
5432 codelist{../IPython/UserConfig/ipythonrc}
5433 \end_inset
5433 \end_inset
5434
5434
5435
5435
5436 \layout Subsection
5436 \layout Subsection
5437
5437
5438
5438
5439 \begin_inset LatexCommand \label{sec:prompts}
5439 \begin_inset LatexCommand \label{sec:prompts}
5440
5440
5441 \end_inset
5441 \end_inset
5442
5442
5443 Fine-tuning your prompt
5443 Fine-tuning your prompt
5444 \layout Standard
5444 \layout Standard
5445
5445
5446 IPython's prompts can be customized using a syntax similar to that of the
5446 IPython's prompts can be customized using a syntax similar to that of the
5447
5447
5448 \family typewriter
5448 \family typewriter
5449 bash
5449 bash
5450 \family default
5450 \family default
5451 shell.
5451 shell.
5452 Many of
5452 Many of
5453 \family typewriter
5453 \family typewriter
5454 bash
5454 bash
5455 \family default
5455 \family default
5456 's escapes are supported, as well as a few additional ones.
5456 's escapes are supported, as well as a few additional ones.
5457 We list them below:
5457 We list them below:
5458 \layout Description
5458 \layout Description
5459
5459
5460
5460
5461 \backslash
5461 \backslash
5462 # the prompt/history count number
5462 # the prompt/history count number
5463 \layout Description
5463 \layout Description
5464
5464
5465
5465
5466 \backslash
5466 \backslash
5467 D the prompt/history count, with the actual digits replaced by dots.
5467 D the prompt/history count, with the actual digits replaced by dots.
5468 Used mainly in continuation prompts (prompt_in2)
5468 Used mainly in continuation prompts (prompt_in2)
5469 \layout Description
5469 \layout Description
5470
5470
5471
5471
5472 \backslash
5472 \backslash
5473 w the current working directory
5473 w the current working directory
5474 \layout Description
5474 \layout Description
5475
5475
5476
5476
5477 \backslash
5477 \backslash
5478 W the basename of current working directory
5478 W the basename of current working directory
5479 \layout Description
5479 \layout Description
5480
5480
5481
5481
5482 \backslash
5482 \backslash
5483 X
5483 X
5484 \emph on
5484 \emph on
5485 n
5485 n
5486 \emph default
5486 \emph default
5487 where
5487 where
5488 \begin_inset Formula $n=0\ldots5.$
5488 \begin_inset Formula $n=0\ldots5.$
5489 \end_inset
5489 \end_inset
5490
5490
5491 The current working directory, with
5491 The current working directory, with
5492 \family typewriter
5492 \family typewriter
5493 $HOME
5493 $HOME
5494 \family default
5494 \family default
5495 replaced by
5495 replaced by
5496 \family typewriter
5496 \family typewriter
5497 ~
5497 ~
5498 \family default
5498 \family default
5499 , and filtered out to contain only
5499 , and filtered out to contain only
5500 \begin_inset Formula $n$
5500 \begin_inset Formula $n$
5501 \end_inset
5501 \end_inset
5502
5502
5503 path elements
5503 path elements
5504 \layout Description
5504 \layout Description
5505
5505
5506
5506
5507 \backslash
5507 \backslash
5508 Y
5508 Y
5509 \emph on
5509 \emph on
5510 n
5510 n
5511 \emph default
5511 \emph default
5512 Similar to
5512 Similar to
5513 \backslash
5513 \backslash
5514 X
5514 X
5515 \emph on
5515 \emph on
5516 n
5516 n
5517 \emph default
5517 \emph default
5518 , but with the
5518 , but with the
5519 \begin_inset Formula $n+1$
5519 \begin_inset Formula $n+1$
5520 \end_inset
5520 \end_inset
5521
5521
5522 element included if it is
5522 element included if it is
5523 \family typewriter
5523 \family typewriter
5524 ~
5524 ~
5525 \family default
5525 \family default
5526 (this is similar to the behavior of the %c
5526 (this is similar to the behavior of the %c
5527 \emph on
5527 \emph on
5528 n
5528 n
5529 \emph default
5529 \emph default
5530 escapes in
5530 escapes in
5531 \family typewriter
5531 \family typewriter
5532 tcsh
5532 tcsh
5533 \family default
5533 \family default
5534 )
5534 )
5535 \layout Description
5535 \layout Description
5536
5536
5537
5537
5538 \backslash
5538 \backslash
5539 u the username of the current user
5539 u the username of the current user
5540 \layout Description
5540 \layout Description
5541
5541
5542
5542
5543 \backslash
5543 \backslash
5544 $ if the effective UID is 0, a #, otherwise a $
5544 $ if the effective UID is 0, a #, otherwise a $
5545 \layout Description
5545 \layout Description
5546
5546
5547
5547
5548 \backslash
5548 \backslash
5549 h the hostname up to the first `.'
5549 h the hostname up to the first `.'
5550 \layout Description
5550 \layout Description
5551
5551
5552
5552
5553 \backslash
5553 \backslash
5554 H the hostname
5554 H the hostname
5555 \layout Description
5555 \layout Description
5556
5556
5557
5557
5558 \backslash
5558 \backslash
5559 n a newline
5559 n a newline
5560 \layout Description
5560 \layout Description
5561
5561
5562
5562
5563 \backslash
5563 \backslash
5564 r a carriage return
5564 r a carriage return
5565 \layout Description
5565 \layout Description
5566
5566
5567
5567
5568 \backslash
5568 \backslash
5569 v IPython version string
5569 v IPython version string
5570 \layout Standard
5570 \layout Standard
5571
5571
5572 In addition to these, ANSI color escapes can be insterted into the prompts,
5572 In addition to these, ANSI color escapes can be insterted into the prompts,
5573 as
5573 as
5574 \family typewriter
5574 \family typewriter
5575
5575
5576 \backslash
5576 \backslash
5577 C_
5577 C_
5578 \emph on
5578 \emph on
5579 ColorName
5579 ColorName
5580 \family default
5580 \family default
5581 \emph default
5581 \emph default
5582 .
5582 .
5583 The list of valid color names is: Black, Blue, Brown, Cyan, DarkGray, Green,
5583 The list of valid color names is: Black, Blue, Brown, Cyan, DarkGray, Green,
5584 LightBlue, LightCyan, LightGray, LightGreen, LightPurple, LightRed, NoColor,
5584 LightBlue, LightCyan, LightGray, LightGreen, LightPurple, LightRed, NoColor,
5585 Normal, Purple, Red, White, Yellow.
5585 Normal, Purple, Red, White, Yellow.
5586 \layout Standard
5586 \layout Standard
5587
5587
5588 Finally, IPython supports the evaluation of arbitrary expressions in your
5588 Finally, IPython supports the evaluation of arbitrary expressions in your
5589 prompt string.
5589 prompt string.
5590 The prompt strings are evaluated through the syntax of PEP 215, but basically
5590 The prompt strings are evaluated through the syntax of PEP 215, but basically
5591 you can use
5591 you can use
5592 \family typewriter
5592 \family typewriter
5593 $x.y
5593 $x.y
5594 \family default
5594 \family default
5595 to expand the value of
5595 to expand the value of
5596 \family typewriter
5596 \family typewriter
5597 x.y
5597 x.y
5598 \family default
5598 \family default
5599 , and for more complicated expressions you can use braces:
5599 , and for more complicated expressions you can use braces:
5600 \family typewriter
5600 \family typewriter
5601 ${foo()+x}
5601 ${foo()+x}
5602 \family default
5602 \family default
5603 will call function
5603 will call function
5604 \family typewriter
5604 \family typewriter
5605 foo
5605 foo
5606 \family default
5606 \family default
5607 and add to it the value of
5607 and add to it the value of
5608 \family typewriter
5608 \family typewriter
5609 x
5609 x
5610 \family default
5610 \family default
5611 , before putting the result into your prompt.
5611 , before putting the result into your prompt.
5612 For example, using
5612 For example, using
5613 \newline
5613 \newline
5614
5614
5615 \family typewriter
5615 \family typewriter
5616 prompt_in1 '${commands.getoutput("uptime")}
5616 prompt_in1 '${commands.getoutput("uptime")}
5617 \backslash
5617 \backslash
5618 nIn [
5618 nIn [
5619 \backslash
5619 \backslash
5620 #]: '
5620 #]: '
5621 \newline
5621 \newline
5622
5622
5623 \family default
5623 \family default
5624 will print the result of the uptime command on each prompt (assuming the
5624 will print the result of the uptime command on each prompt (assuming the
5625
5625
5626 \family typewriter
5626 \family typewriter
5627 commands
5627 commands
5628 \family default
5628 \family default
5629 module has been imported in your
5629 module has been imported in your
5630 \family typewriter
5630 \family typewriter
5631 ipythonrc
5631 ipythonrc
5632 \family default
5632 \family default
5633 file).
5633 file).
5634 \layout Subsubsection
5634 \layout Subsubsection
5635
5635
5636 Prompt examples
5636 Prompt examples
5637 \layout Standard
5637 \layout Standard
5638
5638
5639 The following options in an ipythonrc file will give you IPython's default
5639 The following options in an ipythonrc file will give you IPython's default
5640 prompts:
5640 prompts:
5641 \layout Standard
5641 \layout Standard
5642
5642
5643
5643
5644 \family typewriter
5644 \family typewriter
5645 prompt_in1 'In [
5645 prompt_in1 'In [
5646 \backslash
5646 \backslash
5647 #]:'
5647 #]:'
5648 \newline
5648 \newline
5649 prompt_in2 '\SpecialChar ~
5649 prompt_in2 '\SpecialChar ~
5650 \SpecialChar ~
5650 \SpecialChar ~
5651 \SpecialChar ~
5651 \SpecialChar ~
5652 .
5652 .
5653 \backslash
5653 \backslash
5654 D.:'
5654 D.:'
5655 \newline
5655 \newline
5656 prompt_out 'Out[
5656 prompt_out 'Out[
5657 \backslash
5657 \backslash
5658 #]:'
5658 #]:'
5659 \layout Standard
5659 \layout Standard
5660
5660
5661 which look like this:
5661 which look like this:
5662 \layout Standard
5662 \layout Standard
5663
5663
5664
5664
5665 \family typewriter
5665 \family typewriter
5666 In [1]: 1+2
5666 In [1]: 1+2
5667 \newline
5667 \newline
5668 Out[1]: 3
5668 Out[1]: 3
5669 \layout Standard
5669 \layout Standard
5670
5670
5671
5671
5672 \family typewriter
5672 \family typewriter
5673 In [2]: for i in (1,2,3):
5673 In [2]: for i in (1,2,3):
5674 \newline
5674 \newline
5675
5675
5676 \begin_inset ERT
5676 \begin_inset ERT
5677 status Collapsed
5677 status Collapsed
5678
5678
5679 \layout Standard
5679 \layout Standard
5680
5680
5681 \backslash
5681 \backslash
5682 hspace*{0mm}
5682 hspace*{0mm}
5683 \end_inset
5683 \end_inset
5684
5684
5685 \SpecialChar ~
5685 \SpecialChar ~
5686 \SpecialChar ~
5686 \SpecialChar ~
5687 \SpecialChar ~
5687 \SpecialChar ~
5688 ...: \SpecialChar ~
5688 ...: \SpecialChar ~
5689 \SpecialChar ~
5689 \SpecialChar ~
5690 \SpecialChar ~
5690 \SpecialChar ~
5691 \SpecialChar ~
5691 \SpecialChar ~
5692 print i,
5692 print i,
5693 \newline
5693 \newline
5694
5694
5695 \begin_inset ERT
5695 \begin_inset ERT
5696 status Collapsed
5696 status Collapsed
5697
5697
5698 \layout Standard
5698 \layout Standard
5699
5699
5700 \backslash
5700 \backslash
5701 hspace*{0mm}
5701 hspace*{0mm}
5702 \end_inset
5702 \end_inset
5703
5703
5704 \SpecialChar ~
5704 \SpecialChar ~
5705 \SpecialChar ~
5705 \SpecialChar ~
5706 \SpecialChar ~
5706 \SpecialChar ~
5707 ...:
5707 ...:
5708 \newline
5708 \newline
5709 1 2 3
5709 1 2 3
5710 \layout Standard
5710 \layout Standard
5711
5711
5712 These will give you a very colorful prompt with path information:
5712 These will give you a very colorful prompt with path information:
5713 \layout Standard
5713 \layout Standard
5714
5714
5715
5715
5716 \family typewriter
5716 \family typewriter
5717 #prompt_in1 '
5717 #prompt_in1 '
5718 \backslash
5718 \backslash
5719 C_Red
5719 C_Red
5720 \backslash
5720 \backslash
5721 u
5721 u
5722 \backslash
5722 \backslash
5723 C_Blue[
5723 C_Blue[
5724 \backslash
5724 \backslash
5725 C_Cyan
5725 C_Cyan
5726 \backslash
5726 \backslash
5727 Y1
5727 Y1
5728 \backslash
5728 \backslash
5729 C_Blue]
5729 C_Blue]
5730 \backslash
5730 \backslash
5731 C_LightGreen
5731 C_LightGreen
5732 \backslash
5732 \backslash
5733 #>'
5733 #>'
5734 \newline
5734 \newline
5735 prompt_in2 ' ..
5735 prompt_in2 ' ..
5736 \backslash
5736 \backslash
5737 D>'
5737 D>'
5738 \newline
5738 \newline
5739 prompt_out '<
5739 prompt_out '<
5740 \backslash
5740 \backslash
5741 #>'
5741 #>'
5742 \layout Standard
5742 \layout Standard
5743
5743
5744 which look like this:
5744 which look like this:
5745 \layout Standard
5745 \layout Standard
5746
5746
5747
5747
5748 \family typewriter
5748 \family typewriter
5749 \color red
5749 \color red
5750 fperez
5750 fperez
5751 \color blue
5751 \color blue
5752 [
5752 [
5753 \color cyan
5753 \color cyan
5754 ~/ipython
5754 ~/ipython
5755 \color blue
5755 \color blue
5756 ]
5756 ]
5757 \color green
5757 \color green
5758 1>
5758 1>
5759 \color default
5759 \color default
5760 1+2
5760 1+2
5761 \newline
5761 \newline
5762
5762
5763 \begin_inset ERT
5763 \begin_inset ERT
5764 status Collapsed
5764 status Collapsed
5765
5765
5766 \layout Standard
5766 \layout Standard
5767
5767
5768 \backslash
5768 \backslash
5769 hspace*{0mm}
5769 hspace*{0mm}
5770 \end_inset
5770 \end_inset
5771
5771
5772 \SpecialChar ~
5772 \SpecialChar ~
5773 \SpecialChar ~
5773 \SpecialChar ~
5774 \SpecialChar ~
5774 \SpecialChar ~
5775 \SpecialChar ~
5775 \SpecialChar ~
5776 \SpecialChar ~
5776 \SpecialChar ~
5777 \SpecialChar ~
5777 \SpecialChar ~
5778 \SpecialChar ~
5778 \SpecialChar ~
5779 \SpecialChar ~
5779 \SpecialChar ~
5780 \SpecialChar ~
5780 \SpecialChar ~
5781 \SpecialChar ~
5781 \SpecialChar ~
5782 \SpecialChar ~
5782 \SpecialChar ~
5783 \SpecialChar ~
5783 \SpecialChar ~
5784 \SpecialChar ~
5784 \SpecialChar ~
5785 \SpecialChar ~
5785 \SpecialChar ~
5786 \SpecialChar ~
5786 \SpecialChar ~
5787 \SpecialChar ~
5787 \SpecialChar ~
5788
5788
5789 \color red
5789 \color red
5790 <1>
5790 <1>
5791 \color default
5791 \color default
5792 3
5792 3
5793 \newline
5793 \newline
5794
5794
5795 \color red
5795 \color red
5796 fperez
5796 fperez
5797 \color blue
5797 \color blue
5798 [
5798 [
5799 \color cyan
5799 \color cyan
5800 ~/ipython
5800 ~/ipython
5801 \color blue
5801 \color blue
5802 ]
5802 ]
5803 \color green
5803 \color green
5804 2>
5804 2>
5805 \color default
5805 \color default
5806 for i in (1,2,3):
5806 for i in (1,2,3):
5807 \newline
5807 \newline
5808
5808
5809 \begin_inset ERT
5809 \begin_inset ERT
5810 status Collapsed
5810 status Collapsed
5811
5811
5812 \layout Standard
5812 \layout Standard
5813
5813
5814 \backslash
5814 \backslash
5815 hspace*{0mm}
5815 hspace*{0mm}
5816 \end_inset
5816 \end_inset
5817
5817
5818 \SpecialChar ~
5818 \SpecialChar ~
5819 \SpecialChar ~
5819 \SpecialChar ~
5820 \SpecialChar ~
5820 \SpecialChar ~
5821 \SpecialChar ~
5821 \SpecialChar ~
5822 \SpecialChar ~
5822 \SpecialChar ~
5823 \SpecialChar ~
5823 \SpecialChar ~
5824 \SpecialChar ~
5824 \SpecialChar ~
5825 \SpecialChar ~
5825 \SpecialChar ~
5826 \SpecialChar ~
5826 \SpecialChar ~
5827 \SpecialChar ~
5827 \SpecialChar ~
5828 \SpecialChar ~
5828 \SpecialChar ~
5829 \SpecialChar ~
5829 \SpecialChar ~
5830 \SpecialChar ~
5830 \SpecialChar ~
5831 \SpecialChar ~
5831 \SpecialChar ~
5832 \SpecialChar ~
5832 \SpecialChar ~
5833
5833
5834 \color green
5834 \color green
5835 ...>
5835 ...>
5836 \color default
5836 \color default
5837 \SpecialChar ~
5837 \SpecialChar ~
5838 \SpecialChar ~
5838 \SpecialChar ~
5839 \SpecialChar ~
5839 \SpecialChar ~
5840 \SpecialChar ~
5840 \SpecialChar ~
5841 print i,
5841 print i,
5842 \newline
5842 \newline
5843
5843
5844 \begin_inset ERT
5844 \begin_inset ERT
5845 status Collapsed
5845 status Collapsed
5846
5846
5847 \layout Standard
5847 \layout Standard
5848
5848
5849 \backslash
5849 \backslash
5850 hspace*{0mm}
5850 hspace*{0mm}
5851 \end_inset
5851 \end_inset
5852
5852
5853 \SpecialChar ~
5853 \SpecialChar ~
5854 \SpecialChar ~
5854 \SpecialChar ~
5855 \SpecialChar ~
5855 \SpecialChar ~
5856 \SpecialChar ~
5856 \SpecialChar ~
5857 \SpecialChar ~
5857 \SpecialChar ~
5858 \SpecialChar ~
5858 \SpecialChar ~
5859 \SpecialChar ~
5859 \SpecialChar ~
5860 \SpecialChar ~
5860 \SpecialChar ~
5861 \SpecialChar ~
5861 \SpecialChar ~
5862 \SpecialChar ~
5862 \SpecialChar ~
5863 \SpecialChar ~
5863 \SpecialChar ~
5864 \SpecialChar ~
5864 \SpecialChar ~
5865 \SpecialChar ~
5865 \SpecialChar ~
5866 \SpecialChar ~
5866 \SpecialChar ~
5867 \SpecialChar ~
5867 \SpecialChar ~
5868
5868
5869 \color green
5869 \color green
5870 ...>
5870 ...>
5871 \color default
5871 \color default
5872
5872
5873 \newline
5873 \newline
5874 1 2 3
5874 1 2 3
5875 \layout Standard
5875 \layout Standard
5876
5876
5877 The following shows the usage of dynamic expression evaluation:
5877 The following shows the usage of dynamic expression evaluation:
5878 \layout Subsection
5878 \layout Subsection
5879
5879
5880
5880
5881 \begin_inset LatexCommand \label{sec:profiles}
5881 \begin_inset LatexCommand \label{sec:profiles}
5882
5882
5883 \end_inset
5883 \end_inset
5884
5884
5885 IPython profiles
5885 IPython profiles
5886 \layout Standard
5886 \layout Standard
5887
5887
5888 As we already mentioned, IPython supports the
5888 As we already mentioned, IPython supports the
5889 \family typewriter
5889 \family typewriter
5890 -profile
5890 -profile
5891 \family default
5891 \family default
5892 command-line option (see sec.
5892 command-line option (see sec.
5893
5893
5894 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
5894 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
5895
5895
5896 \end_inset
5896 \end_inset
5897
5897
5898 ).
5898 ).
5899 A profile is nothing more than a particular configuration file like your
5899 A profile is nothing more than a particular configuration file like your
5900 basic
5900 basic
5901 \family typewriter
5901 \family typewriter
5902 ipythonrc
5902 ipythonrc
5903 \family default
5903 \family default
5904 one, but with particular customizations for a specific purpose.
5904 one, but with particular customizations for a specific purpose.
5905 When you start IPython with '
5905 When you start IPython with '
5906 \family typewriter
5906 \family typewriter
5907 ipython -profile <name>
5907 ipython -profile <name>
5908 \family default
5908 \family default
5909 ', it assumes that in your
5909 ', it assumes that in your
5910 \family typewriter
5910 \family typewriter
5911 IPYTHONDIR
5911 IPYTHONDIR
5912 \family default
5912 \family default
5913 there is a file called
5913 there is a file called
5914 \family typewriter
5914 \family typewriter
5915 ipythonrc-<name>
5915 ipythonrc-<name>
5916 \family default
5916 \family default
5917 , and loads it instead of the normal
5917 , and loads it instead of the normal
5918 \family typewriter
5918 \family typewriter
5919 ipythonrc
5919 ipythonrc
5920 \family default
5920 \family default
5921 .
5921 .
5922 \layout Standard
5922 \layout Standard
5923
5923
5924 This system allows you to maintain multiple configurations which load modules,
5924 This system allows you to maintain multiple configurations which load modules,
5925 set options, define functions, etc.
5925 set options, define functions, etc.
5926 suitable for different tasks and activate them in a very simple manner.
5926 suitable for different tasks and activate them in a very simple manner.
5927 In order to avoid having to repeat all of your basic options (common things
5927 In order to avoid having to repeat all of your basic options (common things
5928 that don't change such as your color preferences, for example), any profile
5928 that don't change such as your color preferences, for example), any profile
5929 can include another configuration file.
5929 can include another configuration file.
5930 The most common way to use profiles is then to have each one include your
5930 The most common way to use profiles is then to have each one include your
5931 basic
5931 basic
5932 \family typewriter
5932 \family typewriter
5933 ipythonrc
5933 ipythonrc
5934 \family default
5934 \family default
5935 file as a starting point, and then add further customizations.
5935 file as a starting point, and then add further customizations.
5936 \layout Standard
5936 \layout Standard
5937
5937
5938 In sections
5938 In sections
5939 \begin_inset LatexCommand \ref{sec:syntax-extensions}
5939 \begin_inset LatexCommand \ref{sec:syntax-extensions}
5940
5940
5941 \end_inset
5941 \end_inset
5942
5942
5943 and
5943 and
5944 \begin_inset LatexCommand \ref{sec:Gnuplot}
5944 \begin_inset LatexCommand \ref{sec:Gnuplot}
5945
5945
5946 \end_inset
5946 \end_inset
5947
5947
5948 we discuss some particular profiles which come as part of the standard
5948 we discuss some particular profiles which come as part of the standard
5949 IPython distribution.
5949 IPython distribution.
5950 You may also look in your
5950 You may also look in your
5951 \family typewriter
5951 \family typewriter
5952 IPYTHONDIR
5952 IPYTHONDIR
5953 \family default
5953 \family default
5954 directory, any file whose name begins with
5954 directory, any file whose name begins with
5955 \family typewriter
5955 \family typewriter
5956 ipythonrc-
5956 ipythonrc-
5957 \family default
5957 \family default
5958 is a profile.
5958 is a profile.
5959 You can use those as examples for further customizations to suit your own
5959 You can use those as examples for further customizations to suit your own
5960 needs.
5960 needs.
5961 \layout Section
5961 \layout Section
5962
5962
5963
5963
5964 \begin_inset OptArg
5964 \begin_inset OptArg
5965 collapsed false
5965 collapsed false
5966
5966
5967 \layout Standard
5967 \layout Standard
5968
5968
5969 IPython as default...
5969 IPython as default...
5970 \end_inset
5970 \end_inset
5971
5971
5972 IPython as your default Python environment
5972 IPython as your default Python environment
5973 \layout Standard
5973 \layout Standard
5974
5974
5975 Python honors the environment variable
5975 Python honors the environment variable
5976 \family typewriter
5976 \family typewriter
5977 PYTHONSTARTUP
5977 PYTHONSTARTUP
5978 \family default
5978 \family default
5979 and will execute at startup the file referenced by this variable.
5979 and will execute at startup the file referenced by this variable.
5980 If you put at the end of this file the following two lines of code:
5980 If you put at the end of this file the following two lines of code:
5981 \layout Standard
5981 \layout Standard
5982
5982
5983
5983
5984 \family typewriter
5984 \family typewriter
5985 import IPython
5985 import IPython
5986 \newline
5986 \newline
5987 IPython.Shell.IPShell().mainloop(sys_exit=1)
5987 IPython.Shell.IPShell().mainloop(sys_exit=1)
5988 \layout Standard
5988 \layout Standard
5989
5989
5990 then IPython will be your working environment anytime you start Python.
5990 then IPython will be your working environment anytime you start Python.
5991 The
5991 The
5992 \family typewriter
5992 \family typewriter
5993 sys_exit=1
5993 sys_exit=1
5994 \family default
5994 \family default
5995 is needed to have IPython issue a call to
5995 is needed to have IPython issue a call to
5996 \family typewriter
5996 \family typewriter
5997 sys.exit()
5997 sys.exit()
5998 \family default
5998 \family default
5999 when it finishes, otherwise you'll be back at the normal Python '
5999 when it finishes, otherwise you'll be back at the normal Python '
6000 \family typewriter
6000 \family typewriter
6001 >>>
6001 >>>
6002 \family default
6002 \family default
6003 ' prompt
6003 ' prompt
6004 \begin_inset Foot
6004 \begin_inset Foot
6005 collapsed true
6005 collapsed true
6006
6006
6007 \layout Standard
6007 \layout Standard
6008
6008
6009 Based on an idea by Holger Krekel.
6009 Based on an idea by Holger Krekel.
6010 \end_inset
6010 \end_inset
6011
6011
6012 .
6012 .
6013 \layout Standard
6013 \layout Standard
6014
6014
6015 This is probably useful to developers who manage multiple Python versions
6015 This is probably useful to developers who manage multiple Python versions
6016 and don't want to have correspondingly multiple IPython versions.
6016 and don't want to have correspondingly multiple IPython versions.
6017 Note that in this mode, there is no way to pass IPython any command-line
6017 Note that in this mode, there is no way to pass IPython any command-line
6018 options, as those are trapped first by Python itself.
6018 options, as those are trapped first by Python itself.
6019 \layout Section
6019 \layout Section
6020
6020
6021
6021
6022 \begin_inset LatexCommand \label{sec:embed}
6022 \begin_inset LatexCommand \label{sec:embed}
6023
6023
6024 \end_inset
6024 \end_inset
6025
6025
6026 Embedding IPython
6026 Embedding IPython
6027 \layout Standard
6027 \layout Standard
6028
6028
6029 It is possible to start an IPython instance
6029 It is possible to start an IPython instance
6030 \emph on
6030 \emph on
6031 inside
6031 inside
6032 \emph default
6032 \emph default
6033 your own Python programs.
6033 your own Python programs.
6034 This allows you to evaluate dynamically the state of your code, operate
6034 This allows you to evaluate dynamically the state of your code, operate
6035 with your variables, analyze them, etc.
6035 with your variables, analyze them, etc.
6036 Note however that any changes you make to values while in the shell do
6036 Note however that any changes you make to values while in the shell do
6037
6037
6038 \emph on
6038 \emph on
6039 not
6039 not
6040 \emph default
6040 \emph default
6041 propagate back to the running code, so it is safe to modify your values
6041 propagate back to the running code, so it is safe to modify your values
6042 because you won't break your code in bizarre ways by doing so.
6042 because you won't break your code in bizarre ways by doing so.
6043 \layout Standard
6043 \layout Standard
6044
6044
6045 This feature allows you to easily have a fully functional python environment
6045 This feature allows you to easily have a fully functional python environment
6046 for doing object introspection anywhere in your code with a simple function
6046 for doing object introspection anywhere in your code with a simple function
6047 call.
6047 call.
6048 In some cases a simple print statement is enough, but if you need to do
6048 In some cases a simple print statement is enough, but if you need to do
6049 more detailed analysis of a code fragment this feature can be very valuable.
6049 more detailed analysis of a code fragment this feature can be very valuable.
6050 \layout Standard
6050 \layout Standard
6051
6051
6052 It can also be useful in scientific computing situations where it is common
6052 It can also be useful in scientific computing situations where it is common
6053 to need to do some automatic, computationally intensive part and then stop
6053 to need to do some automatic, computationally intensive part and then stop
6054 to look at data, plots, etc
6054 to look at data, plots, etc
6055 \begin_inset Foot
6055 \begin_inset Foot
6056 collapsed true
6056 collapsed true
6057
6057
6058 \layout Standard
6058 \layout Standard
6059
6059
6060 This functionality was inspired by IDL's combination of the
6060 This functionality was inspired by IDL's combination of the
6061 \family typewriter
6061 \family typewriter
6062 stop
6062 stop
6063 \family default
6063 \family default
6064 keyword and the
6064 keyword and the
6065 \family typewriter
6065 \family typewriter
6066 .continue
6066 .continue
6067 \family default
6067 \family default
6068 executive command, which I have found very useful in the past, and by a
6068 executive command, which I have found very useful in the past, and by a
6069 posting on comp.lang.python by cmkl <cmkleffner-AT-gmx.de> on Dec.
6069 posting on comp.lang.python by cmkl <cmkleffner-AT-gmx.de> on Dec.
6070 06/01 concerning similar uses of pyrepl.
6070 06/01 concerning similar uses of pyrepl.
6071 \end_inset
6071 \end_inset
6072
6072
6073 .
6073 .
6074 Opening an IPython instance will give you full access to your data and
6074 Opening an IPython instance will give you full access to your data and
6075 functions, and you can resume program execution once you are done with
6075 functions, and you can resume program execution once you are done with
6076 the interactive part (perhaps to stop again later, as many times as needed).
6076 the interactive part (perhaps to stop again later, as many times as needed).
6077 \layout Standard
6077 \layout Standard
6078
6078
6079 The following code snippet is the bare minimum you need to include in your
6079 The following code snippet is the bare minimum you need to include in your
6080 Python programs for this to work (detailed examples follow later):
6080 Python programs for this to work (detailed examples follow later):
6081 \layout LyX-Code
6081 \layout LyX-Code
6082
6082
6083 from IPython.Shell import IPShellEmbed
6083 from IPython.Shell import IPShellEmbed
6084 \layout LyX-Code
6084 \layout LyX-Code
6085
6085
6086 ipshell = IPShellEmbed()
6086 ipshell = IPShellEmbed()
6087 \layout LyX-Code
6087 \layout LyX-Code
6088
6088
6089 ipshell() # this call anywhere in your program will start IPython
6089 ipshell() # this call anywhere in your program will start IPython
6090 \layout Standard
6090 \layout Standard
6091
6091
6092 You can run embedded instances even in code which is itself being run at
6092 You can run embedded instances even in code which is itself being run at
6093 the IPython interactive prompt with '
6093 the IPython interactive prompt with '
6094 \family typewriter
6094 \family typewriter
6095 %run\SpecialChar ~
6095 %run\SpecialChar ~
6096 <filename>
6096 <filename>
6097 \family default
6097 \family default
6098 '.
6098 '.
6099 Since it's easy to get lost as to where you are (in your top-level IPython
6099 Since it's easy to get lost as to where you are (in your top-level IPython
6100 or in your embedded one), it's a good idea in such cases to set the in/out
6100 or in your embedded one), it's a good idea in such cases to set the in/out
6101 prompts to something different for the embedded instances.
6101 prompts to something different for the embedded instances.
6102 The code examples below illustrate this.
6102 The code examples below illustrate this.
6103 \layout Standard
6103 \layout Standard
6104
6104
6105 You can also have multiple IPython instances in your program and open them
6105 You can also have multiple IPython instances in your program and open them
6106 separately, for example with different options for data presentation.
6106 separately, for example with different options for data presentation.
6107 If you close and open the same instance multiple times, its prompt counters
6107 If you close and open the same instance multiple times, its prompt counters
6108 simply continue from each execution to the next.
6108 simply continue from each execution to the next.
6109 \layout Standard
6109 \layout Standard
6110
6110
6111 Please look at the docstrings in the
6111 Please look at the docstrings in the
6112 \family typewriter
6112 \family typewriter
6113 Shell.py
6113 Shell.py
6114 \family default
6114 \family default
6115 module for more details on the use of this system.
6115 module for more details on the use of this system.
6116 \layout Standard
6116 \layout Standard
6117
6117
6118 The following sample file illustrating how to use the embedding functionality
6118 The following sample file illustrating how to use the embedding functionality
6119 is provided in the examples directory as
6119 is provided in the examples directory as
6120 \family typewriter
6120 \family typewriter
6121 example-embed.py
6121 example-embed.py
6122 \family default
6122 \family default
6123 .
6123 .
6124 It should be fairly self-explanatory:
6124 It should be fairly self-explanatory:
6125 \layout Standard
6125 \layout Standard
6126
6126
6127
6127
6128 \begin_inset ERT
6128 \begin_inset ERT
6129 status Open
6129 status Open
6130
6130
6131 \layout Standard
6131 \layout Standard
6132
6132
6133 \backslash
6133 \backslash
6134 codelist{examples/example-embed.py}
6134 codelist{examples/example-embed.py}
6135 \end_inset
6135 \end_inset
6136
6136
6137
6137
6138 \layout Standard
6138 \layout Standard
6139
6139
6140 Once you understand how the system functions, you can use the following
6140 Once you understand how the system functions, you can use the following
6141 code fragments in your programs which are ready for cut and paste:
6141 code fragments in your programs which are ready for cut and paste:
6142 \layout Standard
6142 \layout Standard
6143
6143
6144
6144
6145 \begin_inset ERT
6145 \begin_inset ERT
6146 status Open
6146 status Open
6147
6147
6148 \layout Standard
6148 \layout Standard
6149
6149
6150 \backslash
6150 \backslash
6151 codelist{examples/example-embed-short.py}
6151 codelist{examples/example-embed-short.py}
6152 \end_inset
6152 \end_inset
6153
6153
6154
6154
6155 \layout Section
6155 \layout Section
6156
6156
6157
6157
6158 \begin_inset LatexCommand \label{sec:using-pdb}
6158 \begin_inset LatexCommand \label{sec:using-pdb}
6159
6159
6160 \end_inset
6160 \end_inset
6161
6161
6162 Using the Python debugger (
6162 Using the Python debugger (
6163 \family typewriter
6163 \family typewriter
6164 pdb
6164 pdb
6165 \family default
6165 \family default
6166 )
6166 )
6167 \layout Subsection
6167 \layout Subsection
6168
6168
6169 Running entire programs via
6169 Running entire programs via
6170 \family typewriter
6170 \family typewriter
6171 pdb
6171 pdb
6172 \layout Standard
6172 \layout Standard
6173
6173
6174
6174
6175 \family typewriter
6175 \family typewriter
6176 pdb
6176 pdb
6177 \family default
6177 \family default
6178 , the Python debugger, is a powerful interactive debugger which allows you
6178 , the Python debugger, is a powerful interactive debugger which allows you
6179 to step through code, set breakpoints, watch variables, etc.
6179 to step through code, set breakpoints, watch variables, etc.
6180 IPython makes it very easy to start any script under the control of
6180 IPython makes it very easy to start any script under the control of
6181 \family typewriter
6181 \family typewriter
6182 pdb
6182 pdb
6183 \family default
6183 \family default
6184 , regardless of whether you have wrapped it into a
6184 , regardless of whether you have wrapped it into a
6185 \family typewriter
6185 \family typewriter
6186 `main()'
6186 `main()'
6187 \family default
6187 \family default
6188 function or not.
6188 function or not.
6189 For this, simply type
6189 For this, simply type
6190 \family typewriter
6190 \family typewriter
6191 `%run -d myscript'
6191 `%run -d myscript'
6192 \family default
6192 \family default
6193 at an IPython prompt.
6193 at an IPython prompt.
6194 See the
6194 See the
6195 \family typewriter
6195 \family typewriter
6196 %run
6196 %run
6197 \family default
6197 \family default
6198 command's documentation (via
6198 command's documentation (via
6199 \family typewriter
6199 \family typewriter
6200 `%run?'
6200 `%run?'
6201 \family default
6201 \family default
6202 or in Sec.\SpecialChar ~
6202 or in Sec.\SpecialChar ~
6203
6203
6204 \begin_inset LatexCommand \ref{sec:magic}
6204 \begin_inset LatexCommand \ref{sec:magic}
6205
6205
6206 \end_inset
6206 \end_inset
6207
6207
6208 ) for more details, including how to control where
6208 ) for more details, including how to control where
6209 \family typewriter
6209 \family typewriter
6210 pdb
6210 pdb
6211 \family default
6211 \family default
6212 will stop execution first.
6212 will stop execution first.
6213 \layout Standard
6213 \layout Standard
6214
6214
6215 For more information on the use of the
6215 For more information on the use of the
6216 \family typewriter
6216 \family typewriter
6217 pdb
6217 pdb
6218 \family default
6218 \family default
6219 debugger, read the included
6219 debugger, read the included
6220 \family typewriter
6220 \family typewriter
6221 pdb.doc
6221 pdb.doc
6222 \family default
6222 \family default
6223 file (part of the standard Python distribution).
6223 file (part of the standard Python distribution).
6224 On a stock Linux system it is located at
6224 On a stock Linux system it is located at
6225 \family typewriter
6225 \family typewriter
6226 /usr/lib/python2.3/pdb.doc
6226 /usr/lib/python2.3/pdb.doc
6227 \family default
6227 \family default
6228 , but the easiest way to read it is by using the
6228 , but the easiest way to read it is by using the
6229 \family typewriter
6229 \family typewriter
6230 help()
6230 help()
6231 \family default
6231 \family default
6232 function of the
6232 function of the
6233 \family typewriter
6233 \family typewriter
6234 pdb
6234 pdb
6235 \family default
6235 \family default
6236 module as follows (in an IPython prompt):
6236 module as follows (in an IPython prompt):
6237 \layout Standard
6237 \layout Standard
6238
6238
6239
6239
6240 \family typewriter
6240 \family typewriter
6241 In [1]: import pdb
6241 In [1]: import pdb
6242 \newline
6242 \newline
6243 In [2]: pdb.help()
6243 In [2]: pdb.help()
6244 \layout Standard
6244 \layout Standard
6245
6245
6246 This will load the
6246 This will load the
6247 \family typewriter
6247 \family typewriter
6248 pdb.doc
6248 pdb.doc
6249 \family default
6249 \family default
6250 document in a file viewer for you automatically.
6250 document in a file viewer for you automatically.
6251 \layout Subsection
6251 \layout Subsection
6252
6252
6253 Automatic invocation of
6253 Automatic invocation of
6254 \family typewriter
6254 \family typewriter
6255 pdb
6255 pdb
6256 \family default
6256 \family default
6257 on exceptions
6257 on exceptions
6258 \layout Standard
6258 \layout Standard
6259
6259
6260 IPython, if started with the
6260 IPython, if started with the
6261 \family typewriter
6261 \family typewriter
6262 -pdb
6262 -pdb
6263 \family default
6263 \family default
6264 option (or if the option is set in your rc file) can call the Python
6264 option (or if the option is set in your rc file) can call the Python
6265 \family typewriter
6265 \family typewriter
6266 pdb
6266 pdb
6267 \family default
6267 \family default
6268 debugger every time your code triggers an uncaught exception
6268 debugger every time your code triggers an uncaught exception
6269 \begin_inset Foot
6269 \begin_inset Foot
6270 collapsed true
6270 collapsed true
6271
6271
6272 \layout Standard
6272 \layout Standard
6273
6273
6274 Many thanks to Christopher Hart for the request which prompted adding this
6274 Many thanks to Christopher Hart for the request which prompted adding this
6275 feature to IPython.
6275 feature to IPython.
6276 \end_inset
6276 \end_inset
6277
6277
6278 .
6278 .
6279 This feature can also be toggled at any time with the
6279 This feature can also be toggled at any time with the
6280 \family typewriter
6280 \family typewriter
6281 %pdb
6281 %pdb
6282 \family default
6282 \family default
6283 magic command.
6283 magic command.
6284 This can be extremely useful in order to find the origin of subtle bugs,
6284 This can be extremely useful in order to find the origin of subtle bugs,
6285 because
6285 because
6286 \family typewriter
6286 \family typewriter
6287 pdb
6287 pdb
6288 \family default
6288 \family default
6289 opens up at the point in your code which triggered the exception, and while
6289 opens up at the point in your code which triggered the exception, and while
6290 your program is at this point `dead', all the data is still available and
6290 your program is at this point `dead', all the data is still available and
6291 you can walk up and down the stack frame and understand the origin of the
6291 you can walk up and down the stack frame and understand the origin of the
6292 problem.
6292 problem.
6293 \layout Standard
6293 \layout Standard
6294
6294
6295 Furthermore, you can use these debugging facilities both with the embedded
6295 Furthermore, you can use these debugging facilities both with the embedded
6296 IPython mode and without IPython at all.
6296 IPython mode and without IPython at all.
6297 For an embedded shell (see sec.
6297 For an embedded shell (see sec.
6298
6298
6299 \begin_inset LatexCommand \ref{sec:embed}
6299 \begin_inset LatexCommand \ref{sec:embed}
6300
6300
6301 \end_inset
6301 \end_inset
6302
6302
6303 ), simply call the constructor with
6303 ), simply call the constructor with
6304 \family typewriter
6304 \family typewriter
6305 `-pdb'
6305 `-pdb'
6306 \family default
6306 \family default
6307 in the argument string and automatically
6307 in the argument string and automatically
6308 \family typewriter
6308 \family typewriter
6309 pdb
6309 pdb
6310 \family default
6310 \family default
6311 will be called if an uncaught exception is triggered by your code.
6311 will be called if an uncaught exception is triggered by your code.
6312
6312
6313 \layout Standard
6313 \layout Standard
6314
6314
6315 For stand-alone use of the feature in your programs which do not use IPython
6315 For stand-alone use of the feature in your programs which do not use IPython
6316 at all, put the following lines toward the top of your `main' routine:
6316 at all, put the following lines toward the top of your `main' routine:
6317 \layout Standard
6317 \layout Standard
6318 \align left
6318 \align left
6319
6319
6320 \family typewriter
6320 \family typewriter
6321 import sys,IPython.ultraTB
6321 import sys,IPython.ultraTB
6322 \newline
6322 \newline
6323 sys.excepthook = IPython.ultraTB.FormattedTB(mode=`Verbose', color_scheme=`Linux',
6323 sys.excepthook = IPython.ultraTB.FormattedTB(mode=`Verbose', color_scheme=`Linux',
6324 call_pdb=1)
6324 call_pdb=1)
6325 \layout Standard
6325 \layout Standard
6326
6326
6327 The
6327 The
6328 \family typewriter
6328 \family typewriter
6329 mode
6329 mode
6330 \family default
6330 \family default
6331 keyword can be either
6331 keyword can be either
6332 \family typewriter
6332 \family typewriter
6333 `Verbose'
6333 `Verbose'
6334 \family default
6334 \family default
6335 or
6335 or
6336 \family typewriter
6336 \family typewriter
6337 `Plain'
6337 `Plain'
6338 \family default
6338 \family default
6339 , giving either very detailed or normal tracebacks respectively.
6339 , giving either very detailed or normal tracebacks respectively.
6340 The
6340 The
6341 \family typewriter
6341 \family typewriter
6342 color_scheme
6342 color_scheme
6343 \family default
6343 \family default
6344 keyword can be one of
6344 keyword can be one of
6345 \family typewriter
6345 \family typewriter
6346 `NoColor'
6346 `NoColor'
6347 \family default
6347 \family default
6348 ,
6348 ,
6349 \family typewriter
6349 \family typewriter
6350 `Linux'
6350 `Linux'
6351 \family default
6351 \family default
6352 (default) or
6352 (default) or
6353 \family typewriter
6353 \family typewriter
6354 `LightBG'
6354 `LightBG'
6355 \family default
6355 \family default
6356 .
6356 .
6357 These are the same options which can be set in IPython with
6357 These are the same options which can be set in IPython with
6358 \family typewriter
6358 \family typewriter
6359 -colors
6359 -colors
6360 \family default
6360 \family default
6361 and
6361 and
6362 \family typewriter
6362 \family typewriter
6363 -xmode
6363 -xmode
6364 \family default
6364 \family default
6365 .
6365 .
6366 \layout Standard
6366 \layout Standard
6367
6367
6368 This will give any of your programs detailed, colored tracebacks with automatic
6368 This will give any of your programs detailed, colored tracebacks with automatic
6369 invocation of
6369 invocation of
6370 \family typewriter
6370 \family typewriter
6371 pdb
6371 pdb
6372 \family default
6372 \family default
6373 .
6373 .
6374 \layout Section
6374 \layout Section
6375
6375
6376
6376
6377 \begin_inset LatexCommand \label{sec:syntax-extensions}
6377 \begin_inset LatexCommand \label{sec:syntax-extensions}
6378
6378
6379 \end_inset
6379 \end_inset
6380
6380
6381 Extensions for syntax processing
6381 Extensions for syntax processing
6382 \layout Standard
6382 \layout Standard
6383
6383
6384 This isn't for the faint of heart, because the potential for breaking things
6384 This isn't for the faint of heart, because the potential for breaking things
6385 is quite high.
6385 is quite high.
6386 But it can be a very powerful and useful feature.
6386 But it can be a very powerful and useful feature.
6387 In a nutshell, you can redefine the way IPython processes the user input
6387 In a nutshell, you can redefine the way IPython processes the user input
6388 line to accept new, special extensions to the syntax without needing to
6388 line to accept new, special extensions to the syntax without needing to
6389 change any of IPython's own code.
6389 change any of IPython's own code.
6390 \layout Standard
6390 \layout Standard
6391
6391
6392 In the
6392 In the
6393 \family typewriter
6393 \family typewriter
6394 IPython/Extensions
6394 IPython/Extensions
6395 \family default
6395 \family default
6396 directory you will find some examples supplied, which we will briefly describe
6396 directory you will find some examples supplied, which we will briefly describe
6397 now.
6397 now.
6398 These can be used `as is' (and both provide very useful functionality),
6398 These can be used `as is' (and both provide very useful functionality),
6399 or you can use them as a starting point for writing your own extensions.
6399 or you can use them as a starting point for writing your own extensions.
6400 \layout Subsection
6400 \layout Subsection
6401
6401
6402 Pasting of code starting with
6402 Pasting of code starting with
6403 \family typewriter
6403 \family typewriter
6404 `>>>
6404 `>>>
6405 \family default
6405 \family default
6406 ' or
6406 ' or
6407 \family typewriter
6407 \family typewriter
6408 `...
6408 `...
6409
6409
6410 \family default
6410 \family default
6411 '
6411 '
6412 \layout Standard
6412 \layout Standard
6413
6413
6414 In the python tutorial it is common to find code examples which have been
6414 In the python tutorial it is common to find code examples which have been
6415 taken from real python sessions.
6415 taken from real python sessions.
6416 The problem with those is that all the lines begin with either
6416 The problem with those is that all the lines begin with either
6417 \family typewriter
6417 \family typewriter
6418 `>>>
6418 `>>>
6419 \family default
6419 \family default
6420 ' or
6420 ' or
6421 \family typewriter
6421 \family typewriter
6422 `...
6422 `...
6423
6423
6424 \family default
6424 \family default
6425 ', which makes it impossible to paste them all at once.
6425 ', which makes it impossible to paste them all at once.
6426 One must instead do a line by line manual copying, carefully removing the
6426 One must instead do a line by line manual copying, carefully removing the
6427 leading extraneous characters.
6427 leading extraneous characters.
6428 \layout Standard
6428 \layout Standard
6429
6429
6430 This extension identifies those starting characters and removes them from
6430 This extension identifies those starting characters and removes them from
6431 the input automatically, so that one can paste multi-line examples directly
6431 the input automatically, so that one can paste multi-line examples directly
6432 into IPython, saving a lot of time.
6432 into IPython, saving a lot of time.
6433 Please look at the file
6433 Please look at the file
6434 \family typewriter
6434 \family typewriter
6435 InterpreterPasteInput.py
6435 InterpreterPasteInput.py
6436 \family default
6436 \family default
6437 in the
6437 in the
6438 \family typewriter
6438 \family typewriter
6439 IPython/Extensions
6439 IPython/Extensions
6440 \family default
6440 \family default
6441 directory for details on how this is done.
6441 directory for details on how this is done.
6442 \layout Standard
6442 \layout Standard
6443
6443
6444 IPython comes with a special profile enabling this feature, called
6444 IPython comes with a special profile enabling this feature, called
6445 \family typewriter
6445 \family typewriter
6446 tutorial
6446 tutorial
6447 \family default
6447 \family default
6448 \emph on
6448 \emph on
6449 .
6449 .
6450
6450
6451 \emph default
6451 \emph default
6452 Simply start IPython via
6452 Simply start IPython via
6453 \family typewriter
6453 \family typewriter
6454 `ipython\SpecialChar ~
6454 `ipython\SpecialChar ~
6455 -p\SpecialChar ~
6455 -p\SpecialChar ~
6456 tutorial'
6456 tutorial'
6457 \family default
6457 \family default
6458 and the feature will be available.
6458 and the feature will be available.
6459 In a normal IPython session you can activate the feature by importing the
6459 In a normal IPython session you can activate the feature by importing the
6460 corresponding module with:
6460 corresponding module with:
6461 \newline
6461 \newline
6462
6462
6463 \family typewriter
6463 \family typewriter
6464 In [1]: import IPython.Extensions.InterpreterPasteInput
6464 In [1]: import IPython.Extensions.InterpreterPasteInput
6465 \layout Standard
6465 \layout Standard
6466
6466
6467 The following is a 'screenshot' of how things work when this extension is
6467 The following is a 'screenshot' of how things work when this extension is
6468 on, copying an example from the standard tutorial:
6468 on, copying an example from the standard tutorial:
6469 \layout Standard
6469 \layout Standard
6470
6470
6471
6471
6472 \family typewriter
6472 \family typewriter
6473 IPython profile: tutorial
6473 IPython profile: tutorial
6474 \newline
6474 \newline
6475 \SpecialChar ~
6475 \SpecialChar ~
6476
6476
6477 \newline
6477 \newline
6478 *** Pasting of code with ">>>" or "..." has been enabled.
6478 *** Pasting of code with ">>>" or "..." has been enabled.
6479 \newline
6479 \newline
6480 \SpecialChar ~
6480 \SpecialChar ~
6481
6481
6482 \newline
6482 \newline
6483 In [1]: >>> def fib2(n): # return Fibonacci series up to n
6483 In [1]: >>> def fib2(n): # return Fibonacci series up to n
6484 \newline
6484 \newline
6485
6485
6486 \begin_inset ERT
6486 \begin_inset ERT
6487 status Collapsed
6487 status Collapsed
6488
6488
6489 \layout Standard
6489 \layout Standard
6490
6490
6491 \backslash
6491 \backslash
6492 hspace*{0mm}
6492 hspace*{0mm}
6493 \end_inset
6493 \end_inset
6494
6494
6495 \SpecialChar ~
6495 \SpecialChar ~
6496 \SpecialChar ~
6496 \SpecialChar ~
6497 ...: ...\SpecialChar ~
6497 ...: ...\SpecialChar ~
6498 \SpecialChar ~
6498 \SpecialChar ~
6499 \SpecialChar ~
6499 \SpecialChar ~
6500 \SpecialChar ~
6500 \SpecialChar ~
6501 """Return a list containing the Fibonacci series up to n."""
6501 """Return a list containing the Fibonacci series up to n."""
6502 \newline
6502 \newline
6503
6503
6504 \begin_inset ERT
6504 \begin_inset ERT
6505 status Collapsed
6505 status Collapsed
6506
6506
6507 \layout Standard
6507 \layout Standard
6508
6508
6509 \backslash
6509 \backslash
6510 hspace*{0mm}
6510 hspace*{0mm}
6511 \end_inset
6511 \end_inset
6512
6512
6513 \SpecialChar ~
6513 \SpecialChar ~
6514 \SpecialChar ~
6514 \SpecialChar ~
6515 ...: ...\SpecialChar ~
6515 ...: ...\SpecialChar ~
6516 \SpecialChar ~
6516 \SpecialChar ~
6517 \SpecialChar ~
6517 \SpecialChar ~
6518 \SpecialChar ~
6518 \SpecialChar ~
6519 result = []
6519 result = []
6520 \newline
6520 \newline
6521
6521
6522 \begin_inset ERT
6522 \begin_inset ERT
6523 status Collapsed
6523 status Collapsed
6524
6524
6525 \layout Standard
6525 \layout Standard
6526
6526
6527 \backslash
6527 \backslash
6528 hspace*{0mm}
6528 hspace*{0mm}
6529 \end_inset
6529 \end_inset
6530
6530
6531 \SpecialChar ~
6531 \SpecialChar ~
6532 \SpecialChar ~
6532 \SpecialChar ~
6533 ...: ...\SpecialChar ~
6533 ...: ...\SpecialChar ~
6534 \SpecialChar ~
6534 \SpecialChar ~
6535 \SpecialChar ~
6535 \SpecialChar ~
6536 \SpecialChar ~
6536 \SpecialChar ~
6537 a, b = 0, 1
6537 a, b = 0, 1
6538 \newline
6538 \newline
6539
6539
6540 \begin_inset ERT
6540 \begin_inset ERT
6541 status Collapsed
6541 status Collapsed
6542
6542
6543 \layout Standard
6543 \layout Standard
6544
6544
6545 \backslash
6545 \backslash
6546 hspace*{0mm}
6546 hspace*{0mm}
6547 \end_inset
6547 \end_inset
6548
6548
6549 \SpecialChar ~
6549 \SpecialChar ~
6550 \SpecialChar ~
6550 \SpecialChar ~
6551 ...: ...\SpecialChar ~
6551 ...: ...\SpecialChar ~
6552 \SpecialChar ~
6552 \SpecialChar ~
6553 \SpecialChar ~
6553 \SpecialChar ~
6554 \SpecialChar ~
6554 \SpecialChar ~
6555 while b < n:
6555 while b < n:
6556 \newline
6556 \newline
6557
6557
6558 \begin_inset ERT
6558 \begin_inset ERT
6559 status Collapsed
6559 status Collapsed
6560
6560
6561 \layout Standard
6561 \layout Standard
6562
6562
6563 \backslash
6563 \backslash
6564 hspace*{0mm}
6564 hspace*{0mm}
6565 \end_inset
6565 \end_inset
6566
6566
6567 \SpecialChar ~
6567 \SpecialChar ~
6568 \SpecialChar ~
6568 \SpecialChar ~
6569 ...: ...\SpecialChar ~
6569 ...: ...\SpecialChar ~
6570 \SpecialChar ~
6570 \SpecialChar ~
6571 \SpecialChar ~
6571 \SpecialChar ~
6572 \SpecialChar ~
6572 \SpecialChar ~
6573 \SpecialChar ~
6573 \SpecialChar ~
6574 \SpecialChar ~
6574 \SpecialChar ~
6575 \SpecialChar ~
6575 \SpecialChar ~
6576 \SpecialChar ~
6576 \SpecialChar ~
6577 result.append(b)\SpecialChar ~
6577 result.append(b)\SpecialChar ~
6578 \SpecialChar ~
6578 \SpecialChar ~
6579 \SpecialChar ~
6579 \SpecialChar ~
6580 # see below
6580 # see below
6581 \newline
6581 \newline
6582
6582
6583 \begin_inset ERT
6583 \begin_inset ERT
6584 status Collapsed
6584 status Collapsed
6585
6585
6586 \layout Standard
6586 \layout Standard
6587
6587
6588 \backslash
6588 \backslash
6589 hspace*{0mm}
6589 hspace*{0mm}
6590 \end_inset
6590 \end_inset
6591
6591
6592 \SpecialChar ~
6592 \SpecialChar ~
6593 \SpecialChar ~
6593 \SpecialChar ~
6594 ...: ...\SpecialChar ~
6594 ...: ...\SpecialChar ~
6595 \SpecialChar ~
6595 \SpecialChar ~
6596 \SpecialChar ~
6596 \SpecialChar ~
6597 \SpecialChar ~
6597 \SpecialChar ~
6598 \SpecialChar ~
6598 \SpecialChar ~
6599 \SpecialChar ~
6599 \SpecialChar ~
6600 \SpecialChar ~
6600 \SpecialChar ~
6601 \SpecialChar ~
6601 \SpecialChar ~
6602 a, b = b, a+b
6602 a, b = b, a+b
6603 \newline
6603 \newline
6604
6604
6605 \begin_inset ERT
6605 \begin_inset ERT
6606 status Collapsed
6606 status Collapsed
6607
6607
6608 \layout Standard
6608 \layout Standard
6609
6609
6610 \backslash
6610 \backslash
6611 hspace*{0mm}
6611 hspace*{0mm}
6612 \end_inset
6612 \end_inset
6613
6613
6614 \SpecialChar ~
6614 \SpecialChar ~
6615 \SpecialChar ~
6615 \SpecialChar ~
6616 ...: ...\SpecialChar ~
6616 ...: ...\SpecialChar ~
6617 \SpecialChar ~
6617 \SpecialChar ~
6618 \SpecialChar ~
6618 \SpecialChar ~
6619 \SpecialChar ~
6619 \SpecialChar ~
6620 return result
6620 return result
6621 \newline
6621 \newline
6622
6622
6623 \begin_inset ERT
6623 \begin_inset ERT
6624 status Collapsed
6624 status Collapsed
6625
6625
6626 \layout Standard
6626 \layout Standard
6627
6627
6628 \backslash
6628 \backslash
6629 hspace*{0mm}
6629 hspace*{0mm}
6630 \end_inset
6630 \end_inset
6631
6631
6632 \SpecialChar ~
6632 \SpecialChar ~
6633 \SpecialChar ~
6633 \SpecialChar ~
6634 ...:
6634 ...:
6635 \newline
6635 \newline
6636 \SpecialChar ~
6636 \SpecialChar ~
6637
6637
6638 \newline
6638 \newline
6639 In [2]: fib2(10)
6639 In [2]: fib2(10)
6640 \newline
6640 \newline
6641 Out[2]: [1, 1, 2, 3, 5, 8]
6641 Out[2]: [1, 1, 2, 3, 5, 8]
6642 \layout Standard
6642 \layout Standard
6643
6643
6644 Note that as currently written, this extension does
6644 Note that as currently written, this extension does
6645 \emph on
6645 \emph on
6646 not
6646 not
6647 \emph default
6647 \emph default
6648 recognize IPython's prompts for pasting.
6648 recognize IPython's prompts for pasting.
6649 Those are more complicated, since the user can change them very easily,
6649 Those are more complicated, since the user can change them very easily,
6650 they involve numbers and can vary in length.
6650 they involve numbers and can vary in length.
6651 One could however extract all the relevant information from the IPython
6651 One could however extract all the relevant information from the IPython
6652 instance and build an appropriate regular expression.
6652 instance and build an appropriate regular expression.
6653 This is left as an exercise for the reader.
6653 This is left as an exercise for the reader.
6654 \layout Subsection
6654 \layout Subsection
6655
6655
6656 Input of physical quantities with units
6656 Input of physical quantities with units
6657 \layout Standard
6657 \layout Standard
6658
6658
6659 The module
6659 The module
6660 \family typewriter
6660 \family typewriter
6661 PhysicalQInput
6661 PhysicalQInput
6662 \family default
6662 \family default
6663 allows a simplified form of input for physical quantities with units.
6663 allows a simplified form of input for physical quantities with units.
6664 This file is meant to be used in conjunction with the
6664 This file is meant to be used in conjunction with the
6665 \family typewriter
6665 \family typewriter
6666 PhysicalQInteractive
6666 PhysicalQInteractive
6667 \family default
6667 \family default
6668 module (in the same directory) and
6668 module (in the same directory) and
6669 \family typewriter
6669 \family typewriter
6670 Physics.PhysicalQuantities
6670 Physics.PhysicalQuantities
6671 \family default
6671 \family default
6672 from Konrad Hinsen's ScientificPython (
6672 from Konrad Hinsen's ScientificPython (
6673 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/hinsen/scientific.html}
6673 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/hinsen/scientific.html}
6674
6674
6675 \end_inset
6675 \end_inset
6676
6676
6677 ).
6677 ).
6678 \layout Standard
6678 \layout Standard
6679
6679
6680 The
6680 The
6681 \family typewriter
6681 \family typewriter
6682 Physics.PhysicalQuantities
6682 Physics.PhysicalQuantities
6683 \family default
6683 \family default
6684 module defines
6684 module defines
6685 \family typewriter
6685 \family typewriter
6686 PhysicalQuantity
6686 PhysicalQuantity
6687 \family default
6687 \family default
6688 objects, but these must be declared as instances of a class.
6688 objects, but these must be declared as instances of a class.
6689 For example, to define
6689 For example, to define
6690 \family typewriter
6690 \family typewriter
6691 v
6691 v
6692 \family default
6692 \family default
6693 as a velocity of 3\SpecialChar ~
6693 as a velocity of 3\SpecialChar ~
6694 m/s, normally you would write:
6694 m/s, normally you would write:
6695 \family typewriter
6695 \family typewriter
6696
6696
6697 \newline
6697 \newline
6698 In [1]: v = PhysicalQuantity(3,'m/s')
6698 In [1]: v = PhysicalQuantity(3,'m/s')
6699 \layout Standard
6699 \layout Standard
6700
6700
6701 Using the
6701 Using the
6702 \family typewriter
6702 \family typewriter
6703 PhysicalQ_Input
6703 PhysicalQ_Input
6704 \family default
6704 \family default
6705 extension this can be input instead as:
6705 extension this can be input instead as:
6706 \family typewriter
6706 \family typewriter
6707
6707
6708 \newline
6708 \newline
6709 In [1]: v = 3 m/s
6709 In [1]: v = 3 m/s
6710 \family default
6710 \family default
6711
6711
6712 \newline
6712 \newline
6713 which is much more convenient for interactive use (even though it is blatantly
6713 which is much more convenient for interactive use (even though it is blatantly
6714 invalid Python syntax).
6714 invalid Python syntax).
6715 \layout Standard
6715 \layout Standard
6716
6716
6717 The
6717 The
6718 \family typewriter
6718 \family typewriter
6719 physics
6719 physics
6720 \family default
6720 \family default
6721 profile supplied with IPython (enabled via
6721 profile supplied with IPython (enabled via
6722 \family typewriter
6722 \family typewriter
6723 'ipython -p physics'
6723 'ipython -p physics'
6724 \family default
6724 \family default
6725 ) uses these extensions, which you can also activate with:
6725 ) uses these extensions, which you can also activate with:
6726 \layout Standard
6726 \layout Standard
6727
6727
6728
6728
6729 \family typewriter
6729 \family typewriter
6730 from math import * # math MUST be imported BEFORE PhysicalQInteractive
6730 from math import * # math MUST be imported BEFORE PhysicalQInteractive
6731 \newline
6731 \newline
6732 from IPython.Extensions.PhysicalQInteractive import *
6732 from IPython.Extensions.PhysicalQInteractive import *
6733 \newline
6733 \newline
6734 import IPython.Extensions.PhysicalQInput
6734 import IPython.Extensions.PhysicalQInput
6735 \layout Section
6735 \layout Section
6736
6736
6737 IPython as a system shell
6737 IPython as a system shell
6738 \layout Standard
6738 \layout Standard
6739
6739
6740 IPython ships with a special profile called
6740 IPython ships with a special profile called
6741 \family typewriter
6741 \family typewriter
6742 pysh
6742 pysh
6743 \family default
6743 \family default
6744 , which you can activate at the command line as
6744 , which you can activate at the command line as
6745 \family typewriter
6745 \family typewriter
6746 `ipython -p pysh'
6746 `ipython -p pysh'
6747 \family default
6747 \family default
6748 .
6748 .
6749 This loads
6749 This loads
6750 \family typewriter
6750 \family typewriter
6751 InterpreterExec
6751 InterpreterExec
6752 \family default
6752 \family default
6753 , along with some additional facilities and a prompt customized for filesystem
6753 , along with some additional facilities and a prompt customized for filesystem
6754 navigation.
6754 navigation.
6755 \layout Standard
6755 \layout Standard
6756
6756
6757 Note that this does
6757 Note that this does
6758 \emph on
6758 \emph on
6759 not
6759 not
6760 \emph default
6760 \emph default
6761 make IPython a full-fledged system shell.
6761 make IPython a full-fledged system shell.
6762 In particular, it has no job control, so if you type Ctrl-Z (under Unix),
6762 In particular, it has no job control, so if you type Ctrl-Z (under Unix),
6763 you'll suspend pysh itself, not the process you just started.
6763 you'll suspend pysh itself, not the process you just started.
6764
6764
6765 \layout Standard
6765 \layout Standard
6766
6766
6767 What the shell profile allows you to do is to use the convenient and powerful
6767 What the shell profile allows you to do is to use the convenient and powerful
6768 syntax of Python to do quick scripting at the command line.
6768 syntax of Python to do quick scripting at the command line.
6769 Below we describe some of its features.
6769 Below we describe some of its features.
6770 \layout Subsection
6770 \layout Subsection
6771
6771
6772 Aliases
6772 Aliases
6773 \layout Standard
6773 \layout Standard
6774
6774
6775 All of your
6775 All of your
6776 \family typewriter
6776 \family typewriter
6777 $PATH
6777 $PATH
6778 \family default
6778 \family default
6779 has been loaded as IPython aliases, so you should be able to type any normal
6779 has been loaded as IPython aliases, so you should be able to type any normal
6780 system command and have it executed.
6780 system command and have it executed.
6781 See
6781 See
6782 \family typewriter
6782 \family typewriter
6783 %alias?
6783 %alias?
6784 \family default
6784 \family default
6785 and
6785 and
6786 \family typewriter
6786 \family typewriter
6787 %unalias?
6787 %unalias?
6788 \family default
6788 \family default
6789 for details on the alias facilities.
6789 for details on the alias facilities.
6790 See also
6790 See also
6791 \family typewriter
6791 \family typewriter
6792 %rehash?
6792 %rehash?
6793 \family default
6793 \family default
6794 and
6794 and
6795 \family typewriter
6795 \family typewriter
6796 %rehashx?
6796 %rehashx?
6797 \family default
6797 \family default
6798 for details on the mechanism used to load
6798 for details on the mechanism used to load
6799 \family typewriter
6799 \family typewriter
6800 $PATH
6800 $PATH
6801 \family default
6801 \family default
6802 .
6802 .
6803 \layout Subsection
6803 \layout Subsection
6804
6804
6805 Special syntax
6805 Special syntax
6806 \layout Standard
6806 \layout Standard
6807
6807
6808 Any lines which begin with
6808 Any lines which begin with
6809 \family typewriter
6809 \family typewriter
6810 `~'
6810 `~'
6811 \family default
6811 \family default
6812 ,
6812 ,
6813 \family typewriter
6813 \family typewriter
6814 `/'
6814 `/'
6815 \family default
6815 \family default
6816 and
6816 and
6817 \family typewriter
6817 \family typewriter
6818 `.'
6818 `.'
6819 \family default
6819 \family default
6820 will be executed as shell commands instead of as Python code.
6820 will be executed as shell commands instead of as Python code.
6821 The special escapes below are also recognized.
6821 The special escapes below are also recognized.
6822
6822
6823 \family typewriter
6823 \family typewriter
6824 !cmd
6824 !cmd
6825 \family default
6825 \family default
6826 is valid in single or multi-line input, all others are only valid in single-lin
6826 is valid in single or multi-line input, all others are only valid in single-lin
6827 e input:
6827 e input:
6828 \layout Description
6828 \layout Description
6829
6829
6830
6830
6831 \family typewriter
6831 \family typewriter
6832 !cmd
6832 !cmd
6833 \family default
6833 \family default
6834 pass `cmd' directly to the shell
6834 pass `cmd' directly to the shell
6835 \layout Description
6835 \layout Description
6836
6836
6837
6837
6838 \family typewriter
6838 \family typewriter
6839 !!cmd
6839 !!cmd
6840 \family default
6840 \family default
6841 execute `cmd' and return output as a list (split on `
6841 execute `cmd' and return output as a list (split on `
6842 \backslash
6842 \backslash
6843 n')
6843 n')
6844 \layout Description
6844 \layout Description
6845
6845
6846
6846
6847 \family typewriter
6847 \family typewriter
6848 $var=cmd
6848 $var=cmd
6849 \family default
6849 \family default
6850 capture output of cmd into var, as a string
6850 capture output of cmd into var, as a string
6851 \layout Description
6851 \layout Description
6852
6852
6853
6853
6854 \family typewriter
6854 \family typewriter
6855 $$var=cmd
6855 $$var=cmd
6856 \family default
6856 \family default
6857 capture output of cmd into var, as a list (split on `
6857 capture output of cmd into var, as a list (split on `
6858 \backslash
6858 \backslash
6859 n')
6859 n')
6860 \layout Standard
6860 \layout Standard
6861
6861
6862 The
6862 The
6863 \family typewriter
6863 \family typewriter
6864 $
6864 $
6865 \family default
6865 \family default
6866 /
6866 /
6867 \family typewriter
6867 \family typewriter
6868 $$
6868 $$
6869 \family default
6869 \family default
6870 syntaxes make Python variables from system output, which you can later
6870 syntaxes make Python variables from system output, which you can later
6871 use for further scripting.
6871 use for further scripting.
6872 The converse is also possible: when executing an alias or calling to the
6872 The converse is also possible: when executing an alias or calling to the
6873 system via
6873 system via
6874 \family typewriter
6874 \family typewriter
6875 !
6875 !
6876 \family default
6876 \family default
6877 /
6877 /
6878 \family typewriter
6878 \family typewriter
6879 !!
6879 !!
6880 \family default
6880 \family default
6881 , you can expand any python variable or expression by prepending it with
6881 , you can expand any python variable or expression by prepending it with
6882
6882
6883 \family typewriter
6883 \family typewriter
6884 $
6884 $
6885 \family default
6885 \family default
6886 .
6886 .
6887 Full details of the allowed syntax can be found in Python's PEP 215.
6887 Full details of the allowed syntax can be found in Python's PEP 215.
6888 \layout Standard
6888 \layout Standard
6889
6889
6890 A few brief examples will illustrate these (note that the indentation below
6890 A few brief examples will illustrate these (note that the indentation below
6891 may be incorrectly displayed):
6891 may be incorrectly displayed):
6892 \layout Standard
6892 \layout Standard
6893
6893
6894
6894
6895 \family typewriter
6895 \family typewriter
6896 fperez[~/test]|3> !ls *s.py
6896 fperez[~/test]|3> !ls *s.py
6897 \newline
6897 \newline
6898 scopes.py strings.py
6898 scopes.py strings.py
6899 \layout Standard
6899 \layout Standard
6900
6900
6901 ls is an internal alias, so there's no need to use
6901 ls is an internal alias, so there's no need to use
6902 \family typewriter
6902 \family typewriter
6903 !
6903 !
6904 \family default
6904 \family default
6905 :
6905 :
6906 \layout Standard
6906 \layout Standard
6907
6907
6908
6908
6909 \family typewriter
6909 \family typewriter
6910 fperez[~/test]|4> ls *s.py
6910 fperez[~/test]|4> ls *s.py
6911 \newline
6911 \newline
6912 scopes.py* strings.py
6912 scopes.py* strings.py
6913 \layout Standard
6913 \layout Standard
6914
6914
6915 !!ls will return the output into a Python variable:
6915 !!ls will return the output into a Python variable:
6916 \layout Standard
6916 \layout Standard
6917
6917
6918
6918
6919 \family typewriter
6919 \family typewriter
6920 fperez[~/test]|5> !!ls *s.py
6920 fperez[~/test]|5> !!ls *s.py
6921 \newline
6921 \newline
6922
6922
6923 \begin_inset ERT
6923 \begin_inset ERT
6924 status Collapsed
6924 status Collapsed
6925
6925
6926 \layout Standard
6926 \layout Standard
6927
6927
6928 \backslash
6928 \backslash
6929 hspace*{0mm}
6929 hspace*{0mm}
6930 \end_inset
6930 \end_inset
6931
6931
6932 \SpecialChar ~
6932 \SpecialChar ~
6933 \SpecialChar ~
6933 \SpecialChar ~
6934 \SpecialChar ~
6934 \SpecialChar ~
6935 \SpecialChar ~
6935 \SpecialChar ~
6936 \SpecialChar ~
6936 \SpecialChar ~
6937 \SpecialChar ~
6937 \SpecialChar ~
6938 \SpecialChar ~
6938 \SpecialChar ~
6939 \SpecialChar ~
6939 \SpecialChar ~
6940 \SpecialChar ~
6940 \SpecialChar ~
6941 \SpecialChar ~
6941 \SpecialChar ~
6942 \SpecialChar ~
6942 \SpecialChar ~
6943 \SpecialChar ~
6943 \SpecialChar ~
6944 \SpecialChar ~
6944 \SpecialChar ~
6945 \SpecialChar ~
6945 \SpecialChar ~
6946 <5> ['scopes.py', 'strings.py']
6946 <5> ['scopes.py', 'strings.py']
6947 \newline
6947 \newline
6948 fperez[~/test]|6> print _5
6948 fperez[~/test]|6> print _5
6949 \newline
6949 \newline
6950 ['scopes.py', 'strings.py']
6950 ['scopes.py', 'strings.py']
6951 \layout Standard
6951 \layout Standard
6952
6952
6953
6953
6954 \family typewriter
6954 \family typewriter
6955 $
6955 $
6956 \family default
6956 \family default
6957 and
6957 and
6958 \family typewriter
6958 \family typewriter
6959 $$
6959 $$
6960 \family default
6960 \family default
6961 allow direct capture to named variables:
6961 allow direct capture to named variables:
6962 \layout Standard
6962 \layout Standard
6963
6963
6964
6964
6965 \family typewriter
6965 \family typewriter
6966 fperez[~/test]|7> $astr = ls *s.py
6966 fperez[~/test]|7> $astr = ls *s.py
6967 \newline
6967 \newline
6968 fperez[~/test]|8> astr
6968 fperez[~/test]|8> astr
6969 \newline
6969 \newline
6970
6970
6971 \begin_inset ERT
6971 \begin_inset ERT
6972 status Collapsed
6972 status Collapsed
6973
6973
6974 \layout Standard
6974 \layout Standard
6975
6975
6976 \backslash
6976 \backslash
6977 hspace*{0mm}
6977 hspace*{0mm}
6978 \end_inset
6978 \end_inset
6979
6979
6980 \SpecialChar ~
6980 \SpecialChar ~
6981 \SpecialChar ~
6981 \SpecialChar ~
6982 \SpecialChar ~
6982 \SpecialChar ~
6983 \SpecialChar ~
6983 \SpecialChar ~
6984 \SpecialChar ~
6984 \SpecialChar ~
6985 \SpecialChar ~
6985 \SpecialChar ~
6986 \SpecialChar ~
6986 \SpecialChar ~
6987 \SpecialChar ~
6987 \SpecialChar ~
6988 \SpecialChar ~
6988 \SpecialChar ~
6989 \SpecialChar ~
6989 \SpecialChar ~
6990 \SpecialChar ~
6990 \SpecialChar ~
6991 \SpecialChar ~
6991 \SpecialChar ~
6992 \SpecialChar ~
6992 \SpecialChar ~
6993 \SpecialChar ~
6993 \SpecialChar ~
6994 <8> 'scopes.py
6994 <8> 'scopes.py
6995 \backslash
6995 \backslash
6996 nstrings.py'
6996 nstrings.py'
6997 \layout Standard
6997 \layout Standard
6998
6998
6999
6999
7000 \family typewriter
7000 \family typewriter
7001 fperez[~/test]|9> $$alist = ls *s.py
7001 fperez[~/test]|9> $$alist = ls *s.py
7002 \newline
7002 \newline
7003 fperez[~/test]|10> alist
7003 fperez[~/test]|10> alist
7004 \newline
7004 \newline
7005
7005
7006 \begin_inset ERT
7006 \begin_inset ERT
7007 status Collapsed
7007 status Collapsed
7008
7008
7009 \layout Standard
7009 \layout Standard
7010
7010
7011 \backslash
7011 \backslash
7012 hspace*{0mm}
7012 hspace*{0mm}
7013 \end_inset
7013 \end_inset
7014
7014
7015 \SpecialChar ~
7015 \SpecialChar ~
7016 \SpecialChar ~
7016 \SpecialChar ~
7017 \SpecialChar ~
7017 \SpecialChar ~
7018 \SpecialChar ~
7018 \SpecialChar ~
7019 \SpecialChar ~
7019 \SpecialChar ~
7020 \SpecialChar ~
7020 \SpecialChar ~
7021 \SpecialChar ~
7021 \SpecialChar ~
7022 \SpecialChar ~
7022 \SpecialChar ~
7023 \SpecialChar ~
7023 \SpecialChar ~
7024 \SpecialChar ~
7024 \SpecialChar ~
7025 \SpecialChar ~
7025 \SpecialChar ~
7026 \SpecialChar ~
7026 \SpecialChar ~
7027 \SpecialChar ~
7027 \SpecialChar ~
7028 \SpecialChar ~
7028 \SpecialChar ~
7029 <10> ['scopes.py', 'strings.py']
7029 <10> ['scopes.py', 'strings.py']
7030 \layout Standard
7030 \layout Standard
7031
7031
7032 alist is now a normal python list you can loop over.
7032 alist is now a normal python list you can loop over.
7033 Using
7033 Using
7034 \family typewriter
7034 \family typewriter
7035 $
7035 $
7036 \family default
7036 \family default
7037 will expand back the python values when alias calls are made:
7037 will expand back the python values when alias calls are made:
7038 \layout Standard
7038 \layout Standard
7039
7039
7040
7040
7041 \family typewriter
7041 \family typewriter
7042 fperez[~/test]|11> for f in alist:
7042 fperez[~/test]|11> for f in alist:
7043 \newline
7043 \newline
7044
7044
7045 \begin_inset ERT
7045 \begin_inset ERT
7046 status Collapsed
7046 status Collapsed
7047
7047
7048 \layout Standard
7048 \layout Standard
7049
7049
7050 \backslash
7050 \backslash
7051 hspace*{0mm}
7051 hspace*{0mm}
7052 \end_inset
7052 \end_inset
7053
7053
7054 \SpecialChar ~
7054 \SpecialChar ~
7055 \SpecialChar ~
7055 \SpecialChar ~
7056 \SpecialChar ~
7056 \SpecialChar ~
7057 \SpecialChar ~
7057 \SpecialChar ~
7058 \SpecialChar ~
7058 \SpecialChar ~
7059 \SpecialChar ~
7059 \SpecialChar ~
7060 \SpecialChar ~
7060 \SpecialChar ~
7061 \SpecialChar ~
7061 \SpecialChar ~
7062 \SpecialChar ~
7062 \SpecialChar ~
7063 \SpecialChar ~
7063 \SpecialChar ~
7064 \SpecialChar ~
7064 \SpecialChar ~
7065 \SpecialChar ~
7065 \SpecialChar ~
7066 \SpecialChar ~
7066 \SpecialChar ~
7067 \SpecialChar ~
7067 \SpecialChar ~
7068 |..> \SpecialChar ~
7068 |..> \SpecialChar ~
7069 \SpecialChar ~
7069 \SpecialChar ~
7070 \SpecialChar ~
7070 \SpecialChar ~
7071 \SpecialChar ~
7071 \SpecialChar ~
7072 print 'file',f,
7072 print 'file',f,
7073 \newline
7073 \newline
7074
7074
7075 \begin_inset ERT
7075 \begin_inset ERT
7076 status Collapsed
7076 status Collapsed
7077
7077
7078 \layout Standard
7078 \layout Standard
7079
7079
7080 \backslash
7080 \backslash
7081 hspace*{0mm}
7081 hspace*{0mm}
7082 \end_inset
7082 \end_inset
7083
7083
7084 \SpecialChar ~
7084 \SpecialChar ~
7085 \SpecialChar ~
7085 \SpecialChar ~
7086 \SpecialChar ~
7086 \SpecialChar ~
7087 \SpecialChar ~
7087 \SpecialChar ~
7088 \SpecialChar ~
7088 \SpecialChar ~
7089 \SpecialChar ~
7089 \SpecialChar ~
7090 \SpecialChar ~
7090 \SpecialChar ~
7091 \SpecialChar ~
7091 \SpecialChar ~
7092 \SpecialChar ~
7092 \SpecialChar ~
7093 \SpecialChar ~
7093 \SpecialChar ~
7094 \SpecialChar ~
7094 \SpecialChar ~
7095 \SpecialChar ~
7095 \SpecialChar ~
7096 \SpecialChar ~
7096 \SpecialChar ~
7097 \SpecialChar ~
7097 \SpecialChar ~
7098 |..> \SpecialChar ~
7098 |..> \SpecialChar ~
7099 \SpecialChar ~
7099 \SpecialChar ~
7100 \SpecialChar ~
7100 \SpecialChar ~
7101 \SpecialChar ~
7101 \SpecialChar ~
7102 wc -l $f
7102 wc -l $f
7103 \newline
7103 \newline
7104
7104
7105 \begin_inset ERT
7105 \begin_inset ERT
7106 status Collapsed
7106 status Collapsed
7107
7107
7108 \layout Standard
7108 \layout Standard
7109
7109
7110 \backslash
7110 \backslash
7111 hspace*{0mm}
7111 hspace*{0mm}
7112 \end_inset
7112 \end_inset
7113
7113
7114 \SpecialChar ~
7114 \SpecialChar ~
7115 \SpecialChar ~
7115 \SpecialChar ~
7116 \SpecialChar ~
7116 \SpecialChar ~
7117 \SpecialChar ~
7117 \SpecialChar ~
7118 \SpecialChar ~
7118 \SpecialChar ~
7119 \SpecialChar ~
7119 \SpecialChar ~
7120 \SpecialChar ~
7120 \SpecialChar ~
7121 \SpecialChar ~
7121 \SpecialChar ~
7122 \SpecialChar ~
7122 \SpecialChar ~
7123 \SpecialChar ~
7123 \SpecialChar ~
7124 \SpecialChar ~
7124 \SpecialChar ~
7125 \SpecialChar ~
7125 \SpecialChar ~
7126 \SpecialChar ~
7126 \SpecialChar ~
7127 \SpecialChar ~
7127 \SpecialChar ~
7128 |..>
7128 |..>
7129 \newline
7129 \newline
7130 file scopes.py 13 scopes.py
7130 file scopes.py 13 scopes.py
7131 \newline
7131 \newline
7132 file strings.py 4 strings.py
7132 file strings.py 4 strings.py
7133 \layout Standard
7133 \layout Standard
7134
7134
7135 Note that you may need to protect your variables with braces if you want
7135 Note that you may need to protect your variables with braces if you want
7136 to append strings to their names.
7136 to append strings to their names.
7137 To copy all files in alist to
7137 To copy all files in alist to
7138 \family typewriter
7138 \family typewriter
7139 .bak
7139 .bak
7140 \family default
7140 \family default
7141 extensions, you must use:
7141 extensions, you must use:
7142 \layout Standard
7142 \layout Standard
7143
7143
7144
7144
7145 \family typewriter
7145 \family typewriter
7146 fperez[~/test]|12> for f in alist:
7146 fperez[~/test]|12> for f in alist:
7147 \newline
7147 \newline
7148
7148
7149 \begin_inset ERT
7149 \begin_inset ERT
7150 status Collapsed
7150 status Collapsed
7151
7151
7152 \layout Standard
7152 \layout Standard
7153
7153
7154 \backslash
7154 \backslash
7155 hspace*{0mm}
7155 hspace*{0mm}
7156 \end_inset
7156 \end_inset
7157
7157
7158 \SpecialChar ~
7158 \SpecialChar ~
7159 \SpecialChar ~
7159 \SpecialChar ~
7160 \SpecialChar ~
7160 \SpecialChar ~
7161 \SpecialChar ~
7161 \SpecialChar ~
7162 \SpecialChar ~
7162 \SpecialChar ~
7163 \SpecialChar ~
7163 \SpecialChar ~
7164 \SpecialChar ~
7164 \SpecialChar ~
7165 \SpecialChar ~
7165 \SpecialChar ~
7166 \SpecialChar ~
7166 \SpecialChar ~
7167 \SpecialChar ~
7167 \SpecialChar ~
7168 \SpecialChar ~
7168 \SpecialChar ~
7169 \SpecialChar ~
7169 \SpecialChar ~
7170 \SpecialChar ~
7170 \SpecialChar ~
7171 \SpecialChar ~
7171 \SpecialChar ~
7172 |..> \SpecialChar ~
7172 |..> \SpecialChar ~
7173 \SpecialChar ~
7173 \SpecialChar ~
7174 \SpecialChar ~
7174 \SpecialChar ~
7175 \SpecialChar ~
7175 \SpecialChar ~
7176 cp $f ${f}.bak
7176 cp $f ${f}.bak
7177 \layout Standard
7177 \layout Standard
7178
7178
7179 If you try using
7179 If you try using
7180 \family typewriter
7180 \family typewriter
7181 $f.bak
7181 $f.bak
7182 \family default
7182 \family default
7183 , you'll get an AttributeError exception saying that your string object
7183 , you'll get an AttributeError exception saying that your string object
7184 doesn't have a
7184 doesn't have a
7185 \family typewriter
7185 \family typewriter
7186 .bak
7186 .bak
7187 \family default
7187 \family default
7188 attribute.
7188 attribute.
7189 This is because the
7189 This is because the
7190 \family typewriter
7190 \family typewriter
7191 $
7191 $
7192 \family default
7192 \family default
7193 expansion mechanism allows you to expand full Python expressions:
7193 expansion mechanism allows you to expand full Python expressions:
7194 \layout Standard
7194 \layout Standard
7195
7195
7196
7196
7197 \family typewriter
7197 \family typewriter
7198 fperez[~/test]|13> echo "sys.platform is: $sys.platform"
7198 fperez[~/test]|13> echo "sys.platform is: $sys.platform"
7199 \newline
7199 \newline
7200 sys.platform is: linux2
7200 sys.platform is: linux2
7201 \layout Standard
7201 \layout Standard
7202
7202
7203 IPython's input history handling is still active, which allows you to rerun
7203 IPython's input history handling is still active, which allows you to rerun
7204 a single block of multi-line input by simply using exec:
7204 a single block of multi-line input by simply using exec:
7205 \newline
7205 \newline
7206
7206
7207 \family typewriter
7207 \family typewriter
7208 fperez[~/test]|14> $$alist = ls *.eps
7208 fperez[~/test]|14> $$alist = ls *.eps
7209 \newline
7209 \newline
7210 fperez[~/test]|15> exec _i11
7210 fperez[~/test]|15> exec _i11
7211 \newline
7211 \newline
7212 file image2.eps 921 image2.eps
7212 file image2.eps 921 image2.eps
7213 \newline
7213 \newline
7214 file image.eps 921 image.eps
7214 file image.eps 921 image.eps
7215 \layout Standard
7215 \layout Standard
7216
7216
7217 While these are new special-case syntaxes, they are designed to allow very
7217 While these are new special-case syntaxes, they are designed to allow very
7218 efficient use of the shell with minimal typing.
7218 efficient use of the shell with minimal typing.
7219 At an interactive shell prompt, conciseness of expression wins over readability.
7219 At an interactive shell prompt, conciseness of expression wins over readability.
7220 \layout Subsection
7220 \layout Subsection
7221
7221
7222 Useful functions and modules
7222 Useful functions and modules
7223 \layout Standard
7223 \layout Standard
7224
7224
7225 The os, sys and shutil modules from the Python standard library are automaticall
7225 The os, sys and shutil modules from the Python standard library are automaticall
7226 y loaded.
7226 y loaded.
7227 Some additional functions, useful for shell usage, are listed below.
7227 Some additional functions, useful for shell usage, are listed below.
7228 You can request more help about them with `
7228 You can request more help about them with `
7229 \family typewriter
7229 \family typewriter
7230 ?
7230 ?
7231 \family default
7231 \family default
7232 '.
7232 '.
7233 \layout Description
7233 \layout Description
7234
7234
7235
7235
7236 \family typewriter
7236 \family typewriter
7237 shell
7237 shell
7238 \family default
7238 \family default
7239 - execute a command in the underlying system shell
7239 - execute a command in the underlying system shell
7240 \layout Description
7240 \layout Description
7241
7241
7242
7242
7243 \family typewriter
7243 \family typewriter
7244 system
7244 system
7245 \family default
7245 \family default
7246 - like
7246 - like
7247 \family typewriter
7247 \family typewriter
7248 shell()
7248 shell()
7249 \family default
7249 \family default
7250 , but return the exit status of the command
7250 , but return the exit status of the command
7251 \layout Description
7251 \layout Description
7252
7252
7253
7253
7254 \family typewriter
7254 \family typewriter
7255 sout
7255 sout
7256 \family default
7256 \family default
7257 - capture the output of a command as a string
7257 - capture the output of a command as a string
7258 \layout Description
7258 \layout Description
7259
7259
7260
7260
7261 \family typewriter
7261 \family typewriter
7262 lout
7262 lout
7263 \family default
7263 \family default
7264 - capture the output of a command as a list (split on `
7264 - capture the output of a command as a list (split on `
7265 \backslash
7265 \backslash
7266 n')
7266 n')
7267 \layout Description
7267 \layout Description
7268
7268
7269
7269
7270 \family typewriter
7270 \family typewriter
7271 getoutputerror
7271 getoutputerror
7272 \family default
7272 \family default
7273 - capture (output,error) of a shell commandss
7273 - capture (output,error) of a shell commandss
7274 \layout Standard
7274 \layout Standard
7275
7275
7276
7276
7277 \family typewriter
7277 \family typewriter
7278 sout
7278 sout
7279 \family default
7279 \family default
7280 /
7280 /
7281 \family typewriter
7281 \family typewriter
7282 lout
7282 lout
7283 \family default
7283 \family default
7284 are the functional equivalents of
7284 are the functional equivalents of
7285 \family typewriter
7285 \family typewriter
7286 $
7286 $
7287 \family default
7287 \family default
7288 /
7288 /
7289 \family typewriter
7289 \family typewriter
7290 $$
7290 $$
7291 \family default
7291 \family default
7292 .
7292 .
7293 They are provided to allow you to capture system output in the middle of
7293 They are provided to allow you to capture system output in the middle of
7294 true python code, function definitions, etc (where
7294 true python code, function definitions, etc (where
7295 \family typewriter
7295 \family typewriter
7296 $
7296 $
7297 \family default
7297 \family default
7298 and
7298 and
7299 \family typewriter
7299 \family typewriter
7300 $$
7300 $$
7301 \family default
7301 \family default
7302 are invalid).
7302 are invalid).
7303 \layout Subsection
7303 \layout Subsection
7304
7304
7305 Directory management
7305 Directory management
7306 \layout Standard
7306 \layout Standard
7307
7307
7308 Since each command passed by pysh to the underlying system is executed in
7308 Since each command passed by pysh to the underlying system is executed in
7309 a subshell which exits immediately, you can NOT use !cd to navigate the
7309 a subshell which exits immediately, you can NOT use !cd to navigate the
7310 filesystem.
7310 filesystem.
7311 \layout Standard
7311 \layout Standard
7312
7312
7313 Pysh provides its own builtin
7313 Pysh provides its own builtin
7314 \family typewriter
7314 \family typewriter
7315 `%cd
7315 `%cd
7316 \family default
7316 \family default
7317 ' magic command to move in the filesystem (the
7317 ' magic command to move in the filesystem (the
7318 \family typewriter
7318 \family typewriter
7319 %
7319 %
7320 \family default
7320 \family default
7321 is not required with automagic on).
7321 is not required with automagic on).
7322 It also maintains a list of visited directories (use
7322 It also maintains a list of visited directories (use
7323 \family typewriter
7323 \family typewriter
7324 %dhist
7324 %dhist
7325 \family default
7325 \family default
7326 to see it) and allows direct switching to any of them.
7326 to see it) and allows direct switching to any of them.
7327 Type
7327 Type
7328 \family typewriter
7328 \family typewriter
7329 `cd?
7329 `cd?
7330 \family default
7330 \family default
7331 ' for more details.
7331 ' for more details.
7332 \layout Standard
7332 \layout Standard
7333
7333
7334
7334
7335 \family typewriter
7335 \family typewriter
7336 %pushd
7336 %pushd
7337 \family default
7337 \family default
7338 ,
7338 ,
7339 \family typewriter
7339 \family typewriter
7340 %popd
7340 %popd
7341 \family default
7341 \family default
7342 and
7342 and
7343 \family typewriter
7343 \family typewriter
7344 %dirs
7344 %dirs
7345 \family default
7345 \family default
7346 are provided for directory stack handling.
7346 are provided for directory stack handling.
7347 \layout Subsection
7347 \layout Subsection
7348
7348
7349 Prompt customization
7349 Prompt customization
7350 \layout Standard
7350 \layout Standard
7351
7351
7352 The supplied
7352 The supplied
7353 \family typewriter
7353 \family typewriter
7354 ipythonrc-pysh
7354 ipythonrc-pysh
7355 \family default
7355 \family default
7356 profile comes with an example of a very colored and detailed prompt, mainly
7356 profile comes with an example of a very colored and detailed prompt, mainly
7357 to serve as an illustration.
7357 to serve as an illustration.
7358 The valid escape sequences, besides color names, are:
7358 The valid escape sequences, besides color names, are:
7359 \layout Description
7359 \layout Description
7360
7360
7361
7361
7362 \backslash
7362 \backslash
7363 # - Prompt number.
7363 # - Prompt number.
7364 \layout Description
7364 \layout Description
7365
7365
7366
7366
7367 \backslash
7367 \backslash
7368 D - Dots, as many as there are digits in
7368 D - Dots, as many as there are digits in
7369 \backslash
7369 \backslash
7370 # (so they align).
7370 # (so they align).
7371 \layout Description
7371 \layout Description
7372
7372
7373
7373
7374 \backslash
7374 \backslash
7375 w - Current working directory (cwd).
7375 w - Current working directory (cwd).
7376 \layout Description
7376 \layout Description
7377
7377
7378
7378
7379 \backslash
7379 \backslash
7380 W - Basename of current working directory.
7380 W - Basename of current working directory.
7381 \layout Description
7381 \layout Description
7382
7382
7383
7383
7384 \backslash
7384 \backslash
7385 X
7385 X
7386 \emph on
7386 \emph on
7387 N
7387 N
7388 \emph default
7388 \emph default
7389 - Where
7389 - Where
7390 \emph on
7390 \emph on
7391 N
7391 N
7392 \emph default
7392 \emph default
7393 =0..5.
7393 =0..5.
7394 N terms of the cwd, with $HOME written as ~.
7394 N terms of the cwd, with $HOME written as ~.
7395 \layout Description
7395 \layout Description
7396
7396
7397
7397
7398 \backslash
7398 \backslash
7399 Y
7399 Y
7400 \emph on
7400 \emph on
7401 N
7401 N
7402 \emph default
7402 \emph default
7403 - Where
7403 - Where
7404 \emph on
7404 \emph on
7405 N
7405 N
7406 \emph default
7406 \emph default
7407 =0..5.
7407 =0..5.
7408 Like X
7408 Like X
7409 \emph on
7409 \emph on
7410 N
7410 N
7411 \emph default
7411 \emph default
7412 , but if ~ is term
7412 , but if ~ is term
7413 \emph on
7413 \emph on
7414 N
7414 N
7415 \emph default
7415 \emph default
7416 +1 it's also shown.
7416 +1 it's also shown.
7417 \layout Description
7417 \layout Description
7418
7418
7419
7419
7420 \backslash
7420 \backslash
7421 u - Username.
7421 u - Username.
7422 \layout Description
7422 \layout Description
7423
7423
7424
7424
7425 \backslash
7425 \backslash
7426 H - Full hostname.
7426 H - Full hostname.
7427 \layout Description
7427 \layout Description
7428
7428
7429
7429
7430 \backslash
7430 \backslash
7431 h - Hostname up to first '.'
7431 h - Hostname up to first '.'
7432 \layout Description
7432 \layout Description
7433
7433
7434
7434
7435 \backslash
7435 \backslash
7436 $ - Root symbol ($ or #).
7436 $ - Root symbol ($ or #).
7437
7437
7438 \layout Description
7438 \layout Description
7439
7439
7440
7440
7441 \backslash
7441 \backslash
7442 t - Current time, in H:M:S format.
7442 t - Current time, in H:M:S format.
7443 \layout Description
7443 \layout Description
7444
7444
7445
7445
7446 \backslash
7446 \backslash
7447 v - IPython release version.
7447 v - IPython release version.
7448
7448
7449 \layout Description
7449 \layout Description
7450
7450
7451
7451
7452 \backslash
7452 \backslash
7453 n - Newline.
7453 n - Newline.
7454
7454
7455 \layout Description
7455 \layout Description
7456
7456
7457
7457
7458 \backslash
7458 \backslash
7459 r - Carriage return.
7459 r - Carriage return.
7460
7460
7461 \layout Description
7461 \layout Description
7462
7462
7463
7463
7464 \backslash
7464 \backslash
7465
7465
7466 \backslash
7466 \backslash
7467 - An explicitly escaped '
7467 - An explicitly escaped '
7468 \backslash
7468 \backslash
7469 '.
7469 '.
7470 \layout Standard
7470 \layout Standard
7471
7471
7472 You can configure your prompt colors using any ANSI color escape.
7472 You can configure your prompt colors using any ANSI color escape.
7473 Each color escape sets the color for any subsequent text, until another
7473 Each color escape sets the color for any subsequent text, until another
7474 escape comes in and changes things.
7474 escape comes in and changes things.
7475 The valid color escapes are:
7475 The valid color escapes are:
7476 \layout Description
7476 \layout Description
7477
7477
7478
7478
7479 \backslash
7479 \backslash
7480 C_Black
7480 C_Black
7481 \layout Description
7481 \layout Description
7482
7482
7483
7483
7484 \backslash
7484 \backslash
7485 C_Blue
7485 C_Blue
7486 \layout Description
7486 \layout Description
7487
7487
7488
7488
7489 \backslash
7489 \backslash
7490 C_Brown
7490 C_Brown
7491 \layout Description
7491 \layout Description
7492
7492
7493
7493
7494 \backslash
7494 \backslash
7495 C_Cyan
7495 C_Cyan
7496 \layout Description
7496 \layout Description
7497
7497
7498
7498
7499 \backslash
7499 \backslash
7500 C_DarkGray
7500 C_DarkGray
7501 \layout Description
7501 \layout Description
7502
7502
7503
7503
7504 \backslash
7504 \backslash
7505 C_Green
7505 C_Green
7506 \layout Description
7506 \layout Description
7507
7507
7508
7508
7509 \backslash
7509 \backslash
7510 C_LightBlue
7510 C_LightBlue
7511 \layout Description
7511 \layout Description
7512
7512
7513
7513
7514 \backslash
7514 \backslash
7515 C_LightCyan
7515 C_LightCyan
7516 \layout Description
7516 \layout Description
7517
7517
7518
7518
7519 \backslash
7519 \backslash
7520 C_LightGray
7520 C_LightGray
7521 \layout Description
7521 \layout Description
7522
7522
7523
7523
7524 \backslash
7524 \backslash
7525 C_LightGreen
7525 C_LightGreen
7526 \layout Description
7526 \layout Description
7527
7527
7528
7528
7529 \backslash
7529 \backslash
7530 C_LightPurple
7530 C_LightPurple
7531 \layout Description
7531 \layout Description
7532
7532
7533
7533
7534 \backslash
7534 \backslash
7535 C_LightRed
7535 C_LightRed
7536 \layout Description
7536 \layout Description
7537
7537
7538
7538
7539 \backslash
7539 \backslash
7540 C_Purple
7540 C_Purple
7541 \layout Description
7541 \layout Description
7542
7542
7543
7543
7544 \backslash
7544 \backslash
7545 C_Red
7545 C_Red
7546 \layout Description
7546 \layout Description
7547
7547
7548
7548
7549 \backslash
7549 \backslash
7550 C_White
7550 C_White
7551 \layout Description
7551 \layout Description
7552
7552
7553
7553
7554 \backslash
7554 \backslash
7555 C_Yellow
7555 C_Yellow
7556 \layout Description
7556 \layout Description
7557
7557
7558
7558
7559 \backslash
7559 \backslash
7560 C_Normal Stop coloring, defaults to your terminal settings.
7560 C_Normal Stop coloring, defaults to your terminal settings.
7561 \layout Section
7561 \layout Section
7562
7562
7563
7563
7564 \begin_inset LatexCommand \label{sec:Threading-support}
7564 \begin_inset LatexCommand \label{sec:Threading-support}
7565
7565
7566 \end_inset
7566 \end_inset
7567
7567
7568 Threading support
7568 Threading support
7569 \layout Standard
7569 \layout Standard
7570
7570
7571
7571
7572 \series bold
7572 \series bold
7573 WARNING:
7573 WARNING:
7574 \series default
7574 \series default
7575 The threading support is still somewhat experimental, and it has only seen
7575 The threading support is still somewhat experimental, and it has only seen
7576 reasonable testing under Linux.
7576 reasonable testing under Linux.
7577 Threaded code is particularly tricky to debug, and it tends to show extremely
7577 Threaded code is particularly tricky to debug, and it tends to show extremely
7578 platform-dependent behavior.
7578 platform-dependent behavior.
7579 Since I only have access to Linux machines, I will have to rely on user's
7579 Since I only have access to Linux machines, I will have to rely on user's
7580 experiences and assistance for this area of IPython to improve under other
7580 experiences and assistance for this area of IPython to improve under other
7581 platforms.
7581 platforms.
7582 \layout Standard
7582 \layout Standard
7583
7583
7584 IPython, via the
7584 IPython, via the
7585 \family typewriter
7585 \family typewriter
7586 -gthread
7586 -gthread
7587 \family default
7587 \family default
7588 ,
7588 ,
7589 \family typewriter
7589 \family typewriter
7590 -qthread
7590 -qthread
7591 \family default
7591 \family default
7592 and
7592 and
7593 \family typewriter
7593 \family typewriter
7594 -wthread
7594 -wthread
7595 \family default
7595 \family default
7596 options (described in Sec.\SpecialChar ~
7596 options (described in Sec.\SpecialChar ~
7597
7597
7598 \begin_inset LatexCommand \ref{sec:threading-opts}
7598 \begin_inset LatexCommand \ref{sec:threading-opts}
7599
7599
7600 \end_inset
7600 \end_inset
7601
7601
7602 ), can run in multithreaded mode to support pyGTK, Qt and WXPython applications
7602 ), can run in multithreaded mode to support pyGTK, Qt and WXPython applications
7603 respectively.
7603 respectively.
7604 These GUI toolkits need to control the python main loop of execution, so
7604 These GUI toolkits need to control the python main loop of execution, so
7605 under a normal Python interpreter, starting a pyGTK, Qt or WXPython application
7605 under a normal Python interpreter, starting a pyGTK, Qt or WXPython application
7606 will immediately freeze the shell.
7606 will immediately freeze the shell.
7607
7607
7608 \layout Standard
7608 \layout Standard
7609
7609
7610 IPython, with one of these options (you can only use one at a time), separates
7610 IPython, with one of these options (you can only use one at a time), separates
7611 the graphical loop and IPython's code execution run into different threads.
7611 the graphical loop and IPython's code execution run into different threads.
7612 This allows you to test interactively (with
7612 This allows you to test interactively (with
7613 \family typewriter
7613 \family typewriter
7614 %run
7614 %run
7615 \family default
7615 \family default
7616 , for example) your GUI code without blocking.
7616 , for example) your GUI code without blocking.
7617 \layout Standard
7617 \layout Standard
7618
7618
7619 A nice mini-tutorial on using IPython along with the Qt Designer application
7619 A nice mini-tutorial on using IPython along with the Qt Designer application
7620 is available at the SciPy wiki:
7620 is available at the SciPy wiki:
7621 \begin_inset LatexCommand \htmlurl{http://www.scipy.org/wikis/topical_software/QtWithIPythonAndDesigner}
7621 \begin_inset LatexCommand \htmlurl{http://www.scipy.org/wikis/topical_software/QtWithIPythonAndDesigner}
7622
7622
7623 \end_inset
7623 \end_inset
7624
7624
7625 .
7625 .
7626 \layout Subsection
7626 \layout Subsection
7627
7627
7628 Tk issues
7628 Tk issues
7629 \layout Standard
7629 \layout Standard
7630
7630
7631 As indicated in Sec.\SpecialChar ~
7631 As indicated in Sec.\SpecialChar ~
7632
7632
7633 \begin_inset LatexCommand \ref{sec:threading-opts}
7633 \begin_inset LatexCommand \ref{sec:threading-opts}
7634
7634
7635 \end_inset
7635 \end_inset
7636
7636
7637 , a special
7637 , a special
7638 \family typewriter
7638 \family typewriter
7639 -tk
7639 -tk
7640 \family default
7640 \family default
7641 option is provided to try and allow Tk graphical applications to coexist
7641 option is provided to try and allow Tk graphical applications to coexist
7642 interactively with WX, Qt or GTK ones.
7642 interactively with WX, Qt or GTK ones.
7643 Whether this works at all, however, is very platform and configuration
7643 Whether this works at all, however, is very platform and configuration
7644 dependent.
7644 dependent.
7645 Please experiment with simple test cases before committing to using this
7645 Please experiment with simple test cases before committing to using this
7646 combination of Tk and GTK/Qt/WX threading in a production environment.
7646 combination of Tk and GTK/Qt/WX threading in a production environment.
7647 \layout Subsection
7647 \layout Subsection
7648
7648
7649 Signals and Threads
7649 Signals and Threads
7650 \layout Standard
7650 \layout Standard
7651
7651
7652 When any of the thread systems (GTK, Qt or WX) are active, either directly
7652 When any of the thread systems (GTK, Qt or WX) are active, either directly
7653 or via
7653 or via
7654 \family typewriter
7654 \family typewriter
7655 -pylab
7655 -pylab
7656 \family default
7656 \family default
7657 with a threaded backend, it is impossible to interrupt long-running Python
7657 with a threaded backend, it is impossible to interrupt long-running Python
7658 code via
7658 code via
7659 \family typewriter
7659 \family typewriter
7660 Ctrl-C
7660 Ctrl-C
7661 \family default
7661 \family default
7662 .
7662 .
7663 IPython can not pass the KeyboardInterrupt exception (or the underlying
7663 IPython can not pass the KeyboardInterrupt exception (or the underlying
7664
7664
7665 \family typewriter
7665 \family typewriter
7666 SIGINT
7666 SIGINT
7667 \family default
7667 \family default
7668 ) across threads, so any long-running process started from IPython will
7668 ) across threads, so any long-running process started from IPython will
7669 run to completion, or will have to be killed via an external (OS-based)
7669 run to completion, or will have to be killed via an external (OS-based)
7670 mechanism.
7670 mechanism.
7671 \layout Standard
7671 \layout Standard
7672
7672
7673 To the best of my knowledge, this limitation is imposed by the Python interprete
7673 To the best of my knowledge, this limitation is imposed by the Python interprete
7674 r itself, and it comes from the difficulty of writing portable signal/threaded
7674 r itself, and it comes from the difficulty of writing portable signal/threaded
7675 code.
7675 code.
7676 If any user is an expert on this topic and can suggest a better solution,
7676 If any user is an expert on this topic and can suggest a better solution,
7677 I would love to hear about it.
7677 I would love to hear about it.
7678 In the IPython sources, look at the
7678 In the IPython sources, look at the
7679 \family typewriter
7679 \family typewriter
7680 Shell.py
7680 Shell.py
7681 \family default
7681 \family default
7682 module, and in particular at the
7682 module, and in particular at the
7683 \family typewriter
7683 \family typewriter
7684 runcode()
7684 runcode()
7685 \family default
7685 \family default
7686 method.
7686 method.
7687
7687
7688 \layout Subsection
7688 \layout Subsection
7689
7689
7690 I/O pitfalls
7690 I/O pitfalls
7691 \layout Standard
7691 \layout Standard
7692
7692
7693 Be mindful that the Python interpreter switches between threads every
7693 Be mindful that the Python interpreter switches between threads every
7694 \begin_inset Formula $N$
7694 \begin_inset Formula $N$
7695 \end_inset
7695 \end_inset
7696
7696
7697 bytecodes, where the default value as of Python\SpecialChar ~
7697 bytecodes, where the default value as of Python\SpecialChar ~
7698 2.3 is
7698 2.3 is
7699 \begin_inset Formula $N=100.$
7699 \begin_inset Formula $N=100.$
7700 \end_inset
7700 \end_inset
7701
7701
7702 This value can be read by using the
7702 This value can be read by using the
7703 \family typewriter
7703 \family typewriter
7704 sys.getcheckinterval()
7704 sys.getcheckinterval()
7705 \family default
7705 \family default
7706 function, and it can be reset via
7706 function, and it can be reset via
7707 \family typewriter
7707 \family typewriter
7708 sys.setcheckinterval(
7708 sys.setcheckinterval(
7709 \emph on
7709 \emph on
7710 N
7710 N
7711 \emph default
7711 \emph default
7712 )
7712 )
7713 \family default
7713 \family default
7714 .
7714 .
7715 This switching of threads can cause subtly confusing effects if one of
7715 This switching of threads can cause subtly confusing effects if one of
7716 your threads is doing file I/O.
7716 your threads is doing file I/O.
7717 In text mode, most systems only flush file buffers when they encounter
7717 In text mode, most systems only flush file buffers when they encounter
7718 a
7718 a
7719 \family typewriter
7719 \family typewriter
7720 `
7720 `
7721 \backslash
7721 \backslash
7722 n'
7722 n'
7723 \family default
7723 \family default
7724 .
7724 .
7725 An instruction as simple as
7725 An instruction as simple as
7726 \family typewriter
7726 \family typewriter
7727
7727
7728 \newline
7728 \newline
7729 \SpecialChar ~
7729 \SpecialChar ~
7730 \SpecialChar ~
7730 \SpecialChar ~
7731 print >> filehandle,
7731 print >> filehandle,
7732 \begin_inset Quotes eld
7732 \begin_inset Quotes eld
7733 \end_inset
7733 \end_inset
7734
7734
7735 hello world
7735 hello world
7736 \begin_inset Quotes erd
7736 \begin_inset Quotes erd
7737 \end_inset
7737 \end_inset
7738
7738
7739
7739
7740 \family default
7740 \family default
7741
7741
7742 \newline
7742 \newline
7743 actually consists of several bytecodes, so it is possible that the newline
7743 actually consists of several bytecodes, so it is possible that the newline
7744 does not reach your file before the next thread switch.
7744 does not reach your file before the next thread switch.
7745 Similarly, if you are writing to a file in binary mode, the file won't
7745 Similarly, if you are writing to a file in binary mode, the file won't
7746 be flushed until the buffer fills, and your other thread may see apparently
7746 be flushed until the buffer fills, and your other thread may see apparently
7747 truncated files.
7747 truncated files.
7748
7748
7749 \layout Standard
7749 \layout Standard
7750
7750
7751 For this reason, if you are using IPython's thread support and have (for
7751 For this reason, if you are using IPython's thread support and have (for
7752 example) a GUI application which will read data generated by files written
7752 example) a GUI application which will read data generated by files written
7753 to from the IPython thread, the safest approach is to open all of your
7753 to from the IPython thread, the safest approach is to open all of your
7754 files in unbuffered mode (the third argument to the
7754 files in unbuffered mode (the third argument to the
7755 \family typewriter
7755 \family typewriter
7756 file/open
7756 file/open
7757 \family default
7757 \family default
7758 function is the buffering value):
7758 function is the buffering value):
7759 \newline
7759 \newline
7760
7760
7761 \family typewriter
7761 \family typewriter
7762 \SpecialChar ~
7762 \SpecialChar ~
7763 \SpecialChar ~
7763 \SpecialChar ~
7764 filehandle = open(filename,mode,0)
7764 filehandle = open(filename,mode,0)
7765 \layout Standard
7765 \layout Standard
7766
7766
7767 This is obviously a brute force way of avoiding race conditions with the
7767 This is obviously a brute force way of avoiding race conditions with the
7768 file buffering.
7768 file buffering.
7769 If you want to do it cleanly, and you have a resource which is being shared
7769 If you want to do it cleanly, and you have a resource which is being shared
7770 by the interactive IPython loop and your GUI thread, you should really
7770 by the interactive IPython loop and your GUI thread, you should really
7771 handle it with thread locking and syncrhonization properties.
7771 handle it with thread locking and syncrhonization properties.
7772 The Python documentation discusses these.
7772 The Python documentation discusses these.
7773 \layout Section
7773 \layout Section
7774
7774
7775
7775
7776 \begin_inset LatexCommand \label{sec:interactive-demos}
7776 \begin_inset LatexCommand \label{sec:interactive-demos}
7777
7777
7778 \end_inset
7778 \end_inset
7779
7779
7780 Interactive demos with IPython
7780 Interactive demos with IPython
7781 \layout Standard
7781 \layout Standard
7782
7782
7783 IPython ships with a basic system for running scripts interactively in sections,
7783 IPython ships with a basic system for running scripts interactively in sections,
7784 useful when presenting code to audiences.
7784 useful when presenting code to audiences.
7785 A few tags embedded in comments (so that the script remains valid Python
7785 A few tags embedded in comments (so that the script remains valid Python
7786 code) divide a file into separate blocks, and the demo can be run one block
7786 code) divide a file into separate blocks, and the demo can be run one block
7787 at a time, with IPython printing (with syntax highlighting) the block before
7787 at a time, with IPython printing (with syntax highlighting) the block before
7788 executing it, and returning to the interactive prompt after each block.
7788 executing it, and returning to the interactive prompt after each block.
7789 The interactive namespace is updated after each block is run with the contents
7789 The interactive namespace is updated after each block is run with the contents
7790 of the demo's namespace.
7790 of the demo's namespace.
7791 \layout Standard
7791 \layout Standard
7792
7792
7793 This allows you to show a piece of code, run it and then execute interactively
7793 This allows you to show a piece of code, run it and then execute interactively
7794 commands based on the variables just created.
7794 commands based on the variables just created.
7795 Once you want to continue, you simply execute the next block of the demo.
7795 Once you want to continue, you simply execute the next block of the demo.
7796 The following listing shows the markup necessary for dividing a script
7796 The following listing shows the markup necessary for dividing a script
7797 into sections for execution as a demo.
7797 into sections for execution as a demo.
7798 \layout Standard
7798 \layout Standard
7799
7799
7800
7800
7801 \begin_inset ERT
7801 \begin_inset ERT
7802 status Open
7802 status Open
7803
7803
7804 \layout Standard
7804 \layout Standard
7805
7805
7806 \backslash
7806 \backslash
7807 codelist{examples/example-demo.py}
7807 codelist{examples/example-demo.py}
7808 \end_inset
7808 \end_inset
7809
7809
7810
7810
7811 \layout Standard
7811 \layout Standard
7812
7812
7813 In order to run a file as a demo, you must first make a
7813 In order to run a file as a demo, you must first make a
7814 \family typewriter
7814 \family typewriter
7815 Demo
7815 Demo
7816 \family default
7816 \family default
7817 object out of it.
7817 object out of it.
7818 If the file is named
7818 If the file is named
7819 \family typewriter
7819 \family typewriter
7820 myscript.py
7820 myscript.py
7821 \family default
7821 \family default
7822 , the following code will make a demo:
7822 , the following code will make a demo:
7823 \layout LyX-Code
7823 \layout LyX-Code
7824
7824
7825 from IPython.demo import Demo
7825 from IPython.demo import Demo
7826 \layout LyX-Code
7826 \layout LyX-Code
7827
7827
7828 mydemo = Demo('myscript.py')
7828 mydemo = Demo('myscript.py')
7829 \layout Standard
7829 \layout Standard
7830
7830
7831 This creates the
7831 This creates the
7832 \family typewriter
7832 \family typewriter
7833 mydemo
7833 mydemo
7834 \family default
7834 \family default
7835 object, whose blocks you run one at a time by simply calling the object
7835 object, whose blocks you run one at a time by simply calling the object
7836 with no arguments.
7836 with no arguments.
7837 If you have autocall active in IPython (the default), all you need to do
7837 If you have autocall active in IPython (the default), all you need to do
7838 is type
7838 is type
7839 \layout LyX-Code
7839 \layout LyX-Code
7840
7840
7841 mydemo
7841 mydemo
7842 \layout Standard
7842 \layout Standard
7843
7843
7844 and IPython will call it, executing each block.
7844 and IPython will call it, executing each block.
7845 Demo objects can be restarted, you can move forward or back skipping blocks,
7845 Demo objects can be restarted, you can move forward or back skipping blocks,
7846 re-execute the last block, etc.
7846 re-execute the last block, etc.
7847 Simply use the Tab key on a demo object to see its methods, and call
7847 Simply use the Tab key on a demo object to see its methods, and call
7848 \family typewriter
7848 \family typewriter
7849 `?'
7849 `?'
7850 \family default
7850 \family default
7851 on them to see their docstrings for more usage details.
7851 on them to see their docstrings for more usage details.
7852 In addition, the
7852 In addition, the
7853 \family typewriter
7853 \family typewriter
7854 demo
7854 demo
7855 \family default
7855 \family default
7856 module itself contains a comprehensive docstring, which you can access
7856 module itself contains a comprehensive docstring, which you can access
7857 via
7857 via
7858 \layout LyX-Code
7858 \layout LyX-Code
7859
7859
7860 from IPython import demo
7860 from IPython import demo
7861 \layout LyX-Code
7861 \layout LyX-Code
7862
7862
7863 demo?
7863 demo?
7864 \layout Standard
7864 \layout Standard
7865
7865
7866
7866
7867 \series bold
7867 \series bold
7868 Limitations:
7868 Limitations:
7869 \series default
7869 \series default
7870 It is important to note that these demos are limited to fairly simple uses.
7870 It is important to note that these demos are limited to fairly simple uses.
7871 In particular, you can
7871 In particular, you can
7872 \emph on
7872 \emph on
7873 not
7873 not
7874 \emph default
7874 \emph default
7875 put division marks in indented code (loops, if statements, function definitions
7875 put division marks in indented code (loops, if statements, function definitions
7876 , etc.) Supporting something like this would basically require tracking the
7876 , etc.) Supporting something like this would basically require tracking the
7877 internal execution state of the Python interpreter, so only top-level divisions
7877 internal execution state of the Python interpreter, so only top-level divisions
7878 are allowed.
7878 are allowed.
7879 If you want to be able to open an IPython instance at an arbitrary point
7879 If you want to be able to open an IPython instance at an arbitrary point
7880 in a program, you can use IPython's embedding facilities, described in
7880 in a program, you can use IPython's embedding facilities, described in
7881 detail in Sec\SpecialChar \@.
7881 detail in Sec\SpecialChar \@.
7882 \SpecialChar ~
7882 \SpecialChar ~
7883
7883
7884 \begin_inset LatexCommand \ref{sec:embed}
7884 \begin_inset LatexCommand \ref{sec:embed}
7885
7885
7886 \end_inset
7886 \end_inset
7887
7887
7888 .
7888 .
7889 \layout Section
7889 \layout Section
7890
7890
7891
7891
7892 \begin_inset LatexCommand \label{sec:matplotlib-support}
7892 \begin_inset LatexCommand \label{sec:matplotlib-support}
7893
7893
7894 \end_inset
7894 \end_inset
7895
7895
7896 Plotting with
7896 Plotting with
7897 \family typewriter
7897 \family typewriter
7898 matplotlib
7898 matplotlib
7899 \family default
7899 \family default
7900
7900
7901 \layout Standard
7901 \layout Standard
7902
7902
7903 The matplotlib library (
7903 The matplotlib library (
7904 \begin_inset LatexCommand \htmlurl[http://matplotlib.sourceforge.net]{http://matplotlib.sourceforge.net}
7904 \begin_inset LatexCommand \htmlurl[http://matplotlib.sourceforge.net]{http://matplotlib.sourceforge.net}
7905
7905
7906 \end_inset
7906 \end_inset
7907
7907
7908 ) provides high quality 2D plotting for Python.
7908 ) provides high quality 2D plotting for Python.
7909 Matplotlib can produce plots on screen using a variety of GUI toolkits,
7909 Matplotlib can produce plots on screen using a variety of GUI toolkits,
7910 including Tk, GTK and WXPython.
7910 including Tk, GTK and WXPython.
7911 It also provides a number of commands useful for scientific computing,
7911 It also provides a number of commands useful for scientific computing,
7912 all with a syntax compatible with that of the popular Matlab program.
7912 all with a syntax compatible with that of the popular Matlab program.
7913 \layout Standard
7913 \layout Standard
7914
7914
7915 IPython accepts the special option
7915 IPython accepts the special option
7916 \family typewriter
7916 \family typewriter
7917 -pylab
7917 -pylab
7918 \family default
7918 \family default
7919 (Sec.\SpecialChar ~
7919 (Sec.\SpecialChar ~
7920
7920
7921 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
7921 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
7922
7922
7923 \end_inset
7923 \end_inset
7924
7924
7925 ).
7925 ).
7926 This configures it to support matplotlib, honoring the settings in the
7926 This configures it to support matplotlib, honoring the settings in the
7927
7927
7928 \family typewriter
7928 \family typewriter
7929 .matplotlibrc
7929 .matplotlibrc
7930 \family default
7930 \family default
7931 file.
7931 file.
7932 IPython will detect the user's choice of matplotlib GUI backend, and automatica
7932 IPython will detect the user's choice of matplotlib GUI backend, and automatica
7933 lly select the proper threading model to prevent blocking.
7933 lly select the proper threading model to prevent blocking.
7934 It also sets matplotlib in interactive mode and modifies
7934 It also sets matplotlib in interactive mode and modifies
7935 \family typewriter
7935 \family typewriter
7936 %run
7936 %run
7937 \family default
7937 \family default
7938 slightly, so that any matplotlib-based script can be executed using
7938 slightly, so that any matplotlib-based script can be executed using
7939 \family typewriter
7939 \family typewriter
7940 %run
7940 %run
7941 \family default
7941 \family default
7942 and the final
7942 and the final
7943 \family typewriter
7943 \family typewriter
7944 show()
7944 show()
7945 \family default
7945 \family default
7946 command does not block the interactive shell.
7946 command does not block the interactive shell.
7947 \layout Standard
7947 \layout Standard
7948
7948
7949 The
7949 The
7950 \family typewriter
7950 \family typewriter
7951 -pylab
7951 -pylab
7952 \family default
7952 \family default
7953 option must be given first in order for IPython to configure its threading
7953 option must be given first in order for IPython to configure its threading
7954 mode.
7954 mode.
7955 However, you can still issue other options afterwards.
7955 However, you can still issue other options afterwards.
7956 This allows you to have a matplotlib-based environment customized with
7956 This allows you to have a matplotlib-based environment customized with
7957 additional modules using the standard IPython profile mechanism (Sec.\SpecialChar ~
7957 additional modules using the standard IPython profile mechanism (Sec.\SpecialChar ~
7958
7958
7959 \begin_inset LatexCommand \ref{sec:profiles}
7959 \begin_inset LatexCommand \ref{sec:profiles}
7960
7960
7961 \end_inset
7961 \end_inset
7962
7962
7963 ): ``
7963 ): ``
7964 \family typewriter
7964 \family typewriter
7965 ipython -pylab -p myprofile
7965 ipython -pylab -p myprofile
7966 \family default
7966 \family default
7967 '' will load the profile defined in
7967 '' will load the profile defined in
7968 \family typewriter
7968 \family typewriter
7969 ipythonrc-myprofile
7969 ipythonrc-myprofile
7970 \family default
7970 \family default
7971 after configuring matplotlib.
7971 after configuring matplotlib.
7972 \layout Section
7972 \layout Section
7973
7973
7974
7974
7975 \begin_inset LatexCommand \label{sec:Gnuplot}
7975 \begin_inset LatexCommand \label{sec:Gnuplot}
7976
7976
7977 \end_inset
7977 \end_inset
7978
7978
7979 Plotting with
7979 Plotting with
7980 \family typewriter
7980 \family typewriter
7981 Gnuplot
7981 Gnuplot
7982 \layout Standard
7982 \layout Standard
7983
7983
7984 Through the magic extension system described in sec.
7984 Through the magic extension system described in sec.
7985
7985
7986 \begin_inset LatexCommand \ref{sec:magic}
7986 \begin_inset LatexCommand \ref{sec:magic}
7987
7987
7988 \end_inset
7988 \end_inset
7989
7989
7990 , IPython incorporates a mechanism for conveniently interfacing with the
7990 , IPython incorporates a mechanism for conveniently interfacing with the
7991 Gnuplot system (
7991 Gnuplot system (
7992 \begin_inset LatexCommand \htmlurl{http://www.gnuplot.info}
7992 \begin_inset LatexCommand \htmlurl{http://www.gnuplot.info}
7993
7993
7994 \end_inset
7994 \end_inset
7995
7995
7996 ).
7996 ).
7997 Gnuplot is a very complete 2D and 3D plotting package available for many
7997 Gnuplot is a very complete 2D and 3D plotting package available for many
7998 operating systems and commonly included in modern Linux distributions.
7998 operating systems and commonly included in modern Linux distributions.
7999
7999
8000 \layout Standard
8000 \layout Standard
8001
8001
8002 Besides having Gnuplot installed, this functionality requires the
8002 Besides having Gnuplot installed, this functionality requires the
8003 \family typewriter
8003 \family typewriter
8004 Gnuplot.py
8004 Gnuplot.py
8005 \family default
8005 \family default
8006 module for interfacing python with Gnuplot.
8006 module for interfacing python with Gnuplot.
8007 It can be downloaded from:
8007 It can be downloaded from:
8008 \begin_inset LatexCommand \htmlurl{http://gnuplot-py.sourceforge.net}
8008 \begin_inset LatexCommand \htmlurl{http://gnuplot-py.sourceforge.net}
8009
8009
8010 \end_inset
8010 \end_inset
8011
8011
8012 .
8012 .
8013 \layout Subsection
8013 \layout Subsection
8014
8014
8015 Proper Gnuplot configuration
8015 Proper Gnuplot configuration
8016 \layout Standard
8016 \layout Standard
8017
8017
8018 As of version 4.0, Gnuplot has excellent mouse and interactive keyboard support.
8018 As of version 4.0, Gnuplot has excellent mouse and interactive keyboard support.
8019 However, as of
8019 However, as of
8020 \family typewriter
8020 \family typewriter
8021 Gnuplot.py
8021 Gnuplot.py
8022 \family default
8022 \family default
8023 version 1.7, a new option was added to communicate between Python and Gnuplot
8023 version 1.7, a new option was added to communicate between Python and Gnuplot
8024 via FIFOs (pipes).
8024 via FIFOs (pipes).
8025 This mechanism, while fast, also breaks the mouse system.
8025 This mechanism, while fast, also breaks the mouse system.
8026 You must therefore set the variable
8026 You must therefore set the variable
8027 \family typewriter
8027 \family typewriter
8028 prefer_fifo_data
8028 prefer_fifo_data
8029 \family default
8029 \family default
8030 to
8030 to
8031 \family typewriter
8031 \family typewriter
8032 0
8032 0
8033 \family default
8033 \family default
8034 in file
8034 in file
8035 \family typewriter
8035 \family typewriter
8036 gp_unix.py
8036 gp_unix.py
8037 \family default
8037 \family default
8038 if you wish to keep the interactive mouse and keyboard features working
8038 if you wish to keep the interactive mouse and keyboard features working
8039 properly (
8039 properly (
8040 \family typewriter
8040 \family typewriter
8041 prefer_inline_data
8041 prefer_inline_data
8042 \family default
8042 \family default
8043 also must be
8043 also must be
8044 \family typewriter
8044 \family typewriter
8045 0
8045 0
8046 \family default
8046 \family default
8047 , but this is the default so unless you've changed it manually you should
8047 , but this is the default so unless you've changed it manually you should
8048 be fine).
8048 be fine).
8049 \layout Standard
8049 \layout Standard
8050
8050
8051 'Out of the box', Gnuplot is configured with a rather poor set of size,
8051 'Out of the box', Gnuplot is configured with a rather poor set of size,
8052 color and linewidth choices which make the graphs fairly hard to read on
8052 color and linewidth choices which make the graphs fairly hard to read on
8053 modern high-resolution displays (although they work fine on old 640x480
8053 modern high-resolution displays (although they work fine on old 640x480
8054 ones).
8054 ones).
8055 Below is a section of my
8055 Below is a section of my
8056 \family typewriter
8056 \family typewriter
8057 .Xdefaults
8057 .Xdefaults
8058 \family default
8058 \family default
8059 file which I use for having a more convenient Gnuplot setup.
8059 file which I use for having a more convenient Gnuplot setup.
8060 Remember to load it by running
8060 Remember to load it by running
8061 \family typewriter
8061 \family typewriter
8062 `xrdb .Xdefaults`
8062 `xrdb .Xdefaults`
8063 \family default
8063 \family default
8064 :
8064 :
8065 \layout Standard
8065 \layout Standard
8066
8066
8067
8067
8068 \family typewriter
8068 \family typewriter
8069 !******************************************************************
8069 !******************************************************************
8070 \newline
8070 \newline
8071 ! gnuplot options
8071 ! gnuplot options
8072 \newline
8072 \newline
8073 ! modify this for a convenient window size
8073 ! modify this for a convenient window size
8074 \newline
8074 \newline
8075 gnuplot*geometry: 780x580
8075 gnuplot*geometry: 780x580
8076 \layout Standard
8076 \layout Standard
8077
8077
8078
8078
8079 \family typewriter
8079 \family typewriter
8080 ! on-screen font (not for PostScript)
8080 ! on-screen font (not for PostScript)
8081 \newline
8081 \newline
8082 gnuplot*font: -misc-fixed-bold-r-normal--15-120-100-100-c-90-iso8859-1
8082 gnuplot*font: -misc-fixed-bold-r-normal--15-120-100-100-c-90-iso8859-1
8083 \layout Standard
8083 \layout Standard
8084
8084
8085
8085
8086 \family typewriter
8086 \family typewriter
8087 ! color options
8087 ! color options
8088 \newline
8088 \newline
8089 gnuplot*background: black
8089 gnuplot*background: black
8090 \newline
8090 \newline
8091 gnuplot*textColor: white
8091 gnuplot*textColor: white
8092 \newline
8092 \newline
8093 gnuplot*borderColor: white
8093 gnuplot*borderColor: white
8094 \newline
8094 \newline
8095 gnuplot*axisColor: white
8095 gnuplot*axisColor: white
8096 \newline
8096 \newline
8097 gnuplot*line1Color: red
8097 gnuplot*line1Color: red
8098 \newline
8098 \newline
8099 gnuplot*line2Color: green
8099 gnuplot*line2Color: green
8100 \newline
8100 \newline
8101 gnuplot*line3Color: blue
8101 gnuplot*line3Color: blue
8102 \newline
8102 \newline
8103 gnuplot*line4Color: magenta
8103 gnuplot*line4Color: magenta
8104 \newline
8104 \newline
8105 gnuplot*line5Color: cyan
8105 gnuplot*line5Color: cyan
8106 \newline
8106 \newline
8107 gnuplot*line6Color: sienna
8107 gnuplot*line6Color: sienna
8108 \newline
8108 \newline
8109 gnuplot*line7Color: orange
8109 gnuplot*line7Color: orange
8110 \newline
8110 \newline
8111 gnuplot*line8Color: coral
8111 gnuplot*line8Color: coral
8112 \layout Standard
8112 \layout Standard
8113
8113
8114
8114
8115 \family typewriter
8115 \family typewriter
8116 ! multiplicative factor for point styles
8116 ! multiplicative factor for point styles
8117 \newline
8117 \newline
8118 gnuplot*pointsize: 2
8118 gnuplot*pointsize: 2
8119 \layout Standard
8119 \layout Standard
8120
8120
8121
8121
8122 \family typewriter
8122 \family typewriter
8123 ! line width options (in pixels)
8123 ! line width options (in pixels)
8124 \newline
8124 \newline
8125 gnuplot*borderWidth: 2
8125 gnuplot*borderWidth: 2
8126 \newline
8126 \newline
8127 gnuplot*axisWidth: 2
8127 gnuplot*axisWidth: 2
8128 \newline
8128 \newline
8129 gnuplot*line1Width: 2
8129 gnuplot*line1Width: 2
8130 \newline
8130 \newline
8131 gnuplot*line2Width: 2
8131 gnuplot*line2Width: 2
8132 \newline
8132 \newline
8133 gnuplot*line3Width: 2
8133 gnuplot*line3Width: 2
8134 \newline
8134 \newline
8135 gnuplot*line4Width: 2
8135 gnuplot*line4Width: 2
8136 \newline
8136 \newline
8137 gnuplot*line5Width: 2
8137 gnuplot*line5Width: 2
8138 \newline
8138 \newline
8139 gnuplot*line6Width: 2
8139 gnuplot*line6Width: 2
8140 \newline
8140 \newline
8141 gnuplot*line7Width: 2
8141 gnuplot*line7Width: 2
8142 \newline
8142 \newline
8143 gnuplot*line8Width: 2
8143 gnuplot*line8Width: 2
8144 \layout Subsection
8144 \layout Subsection
8145
8145
8146 The
8146 The
8147 \family typewriter
8147 \family typewriter
8148 IPython.GnuplotRuntime
8148 IPython.GnuplotRuntime
8149 \family default
8149 \family default
8150 module
8150 module
8151 \layout Standard
8151 \layout Standard
8152
8152
8153 IPython includes a module called
8153 IPython includes a module called
8154 \family typewriter
8154 \family typewriter
8155 Gnuplot2.py
8155 Gnuplot2.py
8156 \family default
8156 \family default
8157 which extends and improves the default
8157 which extends and improves the default
8158 \family typewriter
8158 \family typewriter
8159 Gnuplot
8159 Gnuplot
8160 \family default
8160 \family default
8161 .
8161 .
8162 \family typewriter
8162 \family typewriter
8163 py
8163 py
8164 \family default
8164 \family default
8165 (which it still relies upon).
8165 (which it still relies upon).
8166 For example, the new
8166 For example, the new
8167 \family typewriter
8167 \family typewriter
8168 plot
8168 plot
8169 \family default
8169 \family default
8170 function adds several improvements to the original making it more convenient
8170 function adds several improvements to the original making it more convenient
8171 for interactive use, and
8171 for interactive use, and
8172 \family typewriter
8172 \family typewriter
8173 hardcopy
8173 hardcopy
8174 \family default
8174 \family default
8175 fixes a bug in the original which under some circumstances blocks the creation
8175 fixes a bug in the original which under some circumstances blocks the creation
8176 of PostScript output.
8176 of PostScript output.
8177 \layout Standard
8177 \layout Standard
8178
8178
8179 For scripting use,
8179 For scripting use,
8180 \family typewriter
8180 \family typewriter
8181 GnuplotRuntime.py
8181 GnuplotRuntime.py
8182 \family default
8182 \family default
8183 is provided, which wraps
8183 is provided, which wraps
8184 \family typewriter
8184 \family typewriter
8185 Gnuplot2.py
8185 Gnuplot2.py
8186 \family default
8186 \family default
8187 and creates a series of global aliases.
8187 and creates a series of global aliases.
8188 These make it easy to control Gnuplot plotting jobs through the Python
8188 These make it easy to control Gnuplot plotting jobs through the Python
8189 language.
8189 language.
8190 \layout Standard
8190 \layout Standard
8191
8191
8192 Below is some example code which illustrates how to configure Gnuplot inside
8192 Below is some example code which illustrates how to configure Gnuplot inside
8193 your own programs but have it available for further interactive use through
8193 your own programs but have it available for further interactive use through
8194 an embedded IPython instance.
8194 an embedded IPython instance.
8195 Simply run this file at a system prompt.
8195 Simply run this file at a system prompt.
8196 This file is provided as
8196 This file is provided as
8197 \family typewriter
8197 \family typewriter
8198 example-gnuplot.py
8198 example-gnuplot.py
8199 \family default
8199 \family default
8200 in the examples directory:
8200 in the examples directory:
8201 \layout Standard
8201 \layout Standard
8202
8202
8203
8203
8204 \begin_inset ERT
8204 \begin_inset ERT
8205 status Open
8205 status Open
8206
8206
8207 \layout Standard
8207 \layout Standard
8208
8208
8209 \backslash
8209 \backslash
8210 codelist{examples/example-gnuplot.py}
8210 codelist{examples/example-gnuplot.py}
8211 \end_inset
8211 \end_inset
8212
8212
8213
8213
8214 \layout Subsection
8214 \layout Subsection
8215
8215
8216 The
8216 The
8217 \family typewriter
8217 \family typewriter
8218 numeric
8218 numeric
8219 \family default
8219 \family default
8220 profile: a scientific computing environment
8220 profile: a scientific computing environment
8221 \layout Standard
8221 \layout Standard
8222
8222
8223 The
8223 The
8224 \family typewriter
8224 \family typewriter
8225 numeric
8225 numeric
8226 \family default
8226 \family default
8227 IPython profile, which you can activate with
8227 IPython profile, which you can activate with
8228 \family typewriter
8228 \family typewriter
8229 `ipython -p numeric
8229 `ipython -p numeric
8230 \family default
8230 \family default
8231 ' will automatically load the IPython Gnuplot extensions (plus Numeric and
8231 ' will automatically load the IPython Gnuplot extensions (plus Numeric and
8232 other useful things for numerical computing), contained in the
8232 other useful things for numerical computing), contained in the
8233 \family typewriter
8233 \family typewriter
8234 IPython.GnuplotInteractive
8234 IPython.GnuplotInteractive
8235 \family default
8235 \family default
8236 module.
8236 module.
8237 This will create the globals
8237 This will create the globals
8238 \family typewriter
8238 \family typewriter
8239 Gnuplot
8239 Gnuplot
8240 \family default
8240 \family default
8241 (an alias to the improved Gnuplot2 module),
8241 (an alias to the improved Gnuplot2 module),
8242 \family typewriter
8242 \family typewriter
8243 gp
8243 gp
8244 \family default
8244 \family default
8245 (a Gnuplot active instance), the new magic commands
8245 (a Gnuplot active instance), the new magic commands
8246 \family typewriter
8246 \family typewriter
8247 %gpc
8247 %gpc
8248 \family default
8248 \family default
8249 and
8249 and
8250 \family typewriter
8250 \family typewriter
8251 %gp_set_instance
8251 %gp_set_instance
8252 \family default
8252 \family default
8253 and several other convenient globals.
8253 and several other convenient globals.
8254 Type
8254 Type
8255 \family typewriter
8255 \family typewriter
8256 gphelp()
8256 gphelp()
8257 \family default
8257 \family default
8258 for further details.
8258 for further details.
8259 \layout Standard
8259 \layout Standard
8260
8260
8261 This should turn IPython into a convenient environment for numerical computing,
8261 This should turn IPython into a convenient environment for numerical computing,
8262 with all the functions in the NumPy library and the Gnuplot facilities
8262 with all the functions in the NumPy library and the Gnuplot facilities
8263 for plotting.
8263 for plotting.
8264 Further improvements can be obtained by loading the SciPy libraries for
8264 Further improvements can be obtained by loading the SciPy libraries for
8265 scientific computing, available at
8265 scientific computing, available at
8266 \begin_inset LatexCommand \htmlurl{http://scipy.org}
8266 \begin_inset LatexCommand \htmlurl{http://scipy.org}
8267
8267
8268 \end_inset
8268 \end_inset
8269
8269
8270 .
8270 .
8271 \layout Standard
8271 \layout Standard
8272
8272
8273 If you are in the middle of a working session with numerical objects and
8273 If you are in the middle of a working session with numerical objects and
8274 need to plot them but you didn't start the
8274 need to plot them but you didn't start the
8275 \family typewriter
8275 \family typewriter
8276 numeric
8276 numeric
8277 \family default
8277 \family default
8278 profile, you can load these extensions at any time by typing
8278 profile, you can load these extensions at any time by typing
8279 \newline
8279 \newline
8280
8280
8281 \family typewriter
8281 \family typewriter
8282 from IPython.GnuplotInteractive import *
8282 from IPython.GnuplotInteractive import *
8283 \newline
8283 \newline
8284
8284
8285 \family default
8285 \family default
8286 at the IPython prompt.
8286 at the IPython prompt.
8287 This will allow you to keep your objects intact and start using Gnuplot
8287 This will allow you to keep your objects intact and start using Gnuplot
8288 to view them.
8288 to view them.
8289 \layout Section
8289 \layout Section
8290
8290
8291 Reporting bugs
8291 Reporting bugs
8292 \layout Subsection*
8292 \layout Subsection*
8293
8293
8294 Automatic crash reports
8294 Automatic crash reports
8295 \layout Standard
8295 \layout Standard
8296
8296
8297 Ideally, IPython itself shouldn't crash.
8297 Ideally, IPython itself shouldn't crash.
8298 It will catch exceptions produced by you, but bugs in its internals will
8298 It will catch exceptions produced by you, but bugs in its internals will
8299 still crash it.
8299 still crash it.
8300 \layout Standard
8300 \layout Standard
8301
8301
8302 In such a situation, IPython will leave a file named
8302 In such a situation, IPython will leave a file named
8303 \family typewriter
8303 \family typewriter
8304 IPython_crash_report.txt
8304 IPython_crash_report.txt
8305 \family default
8305 \family default
8306 in your IPYTHONDIR directory (that way if crashes happen several times
8306 in your IPYTHONDIR directory (that way if crashes happen several times
8307 it won't litter many directories, the post-mortem file is always located
8307 it won't litter many directories, the post-mortem file is always located
8308 in the same place and new occurrences just overwrite the previous one).
8308 in the same place and new occurrences just overwrite the previous one).
8309 If you can mail this file to the developers (see sec.
8309 If you can mail this file to the developers (see sec.
8310
8310
8311 \begin_inset LatexCommand \ref{sec:credits}
8311 \begin_inset LatexCommand \ref{sec:credits}
8312
8312
8313 \end_inset
8313 \end_inset
8314
8314
8315 for names and addresses), it will help us
8315 for names and addresses), it will help us
8316 \emph on
8316 \emph on
8317 a lot
8317 a lot
8318 \emph default
8318 \emph default
8319 in understanding the cause of the problem and fixing it sooner.
8319 in understanding the cause of the problem and fixing it sooner.
8320 \layout Subsection*
8320 \layout Subsection*
8321
8321
8322 The bug tracker
8322 The bug tracker
8323 \layout Standard
8323 \layout Standard
8324
8324
8325 IPython also has an online bug-tracker, located at
8325 IPython also has an online bug-tracker, located at
8326 \begin_inset LatexCommand \htmlurl{http://www.scipy.net/roundup/ipython}
8326 \begin_inset LatexCommand \htmlurl{http://www.scipy.net/roundup/ipython}
8327
8327
8328 \end_inset
8328 \end_inset
8329
8329
8330 .
8330 .
8331 In addition to mailing the developers, it would be a good idea to file
8331 In addition to mailing the developers, it would be a good idea to file
8332 a bug report here.
8332 a bug report here.
8333 This will ensure that the issue is properly followed to conclusion.
8333 This will ensure that the issue is properly followed to conclusion.
8334 \layout Standard
8334 \layout Standard
8335
8335
8336 You can also use this bug tracker to file feature requests.
8336 You can also use this bug tracker to file feature requests.
8337 \layout Section
8337 \layout Section
8338
8338
8339 Brief history
8339 Brief history
8340 \layout Subsection
8340 \layout Subsection
8341
8341
8342 Origins
8342 Origins
8343 \layout Standard
8343 \layout Standard
8344
8344
8345 The current IPython system grew out of the following three projects:
8345 The current IPython system grew out of the following three projects:
8346 \layout List
8346 \layout List
8347 \labelwidthstring 00.00.0000
8347 \labelwidthstring 00.00.0000
8348
8348
8349 ipython by Fernando PΓ©rez.
8349 ipython by Fernando PΓ©rez.
8350 I was working on adding Mathematica-type prompts and a flexible configuration
8350 I was working on adding Mathematica-type prompts and a flexible configuration
8351 system (something better than
8351 system (something better than
8352 \family typewriter
8352 \family typewriter
8353 $PYTHONSTARTUP
8353 $PYTHONSTARTUP
8354 \family default
8354 \family default
8355 ) to the standard Python interactive interpreter.
8355 ) to the standard Python interactive interpreter.
8356 \layout List
8356 \layout List
8357 \labelwidthstring 00.00.0000
8357 \labelwidthstring 00.00.0000
8358
8358
8359 IPP by Janko Hauser.
8359 IPP by Janko Hauser.
8360 Very well organized, great usability.
8360 Very well organized, great usability.
8361 Had an old help system.
8361 Had an old help system.
8362 IPP was used as the `container' code into which I added the functionality
8362 IPP was used as the `container' code into which I added the functionality
8363 from ipython and LazyPython.
8363 from ipython and LazyPython.
8364 \layout List
8364 \layout List
8365 \labelwidthstring 00.00.0000
8365 \labelwidthstring 00.00.0000
8366
8366
8367 LazyPython by Nathan Gray.
8367 LazyPython by Nathan Gray.
8368 Simple but
8368 Simple but
8369 \emph on
8369 \emph on
8370 very
8370 very
8371 \emph default
8371 \emph default
8372 powerful.
8372 powerful.
8373 The quick syntax (auto parens, auto quotes) and verbose/colored tracebacks
8373 The quick syntax (auto parens, auto quotes) and verbose/colored tracebacks
8374 were all taken from here.
8374 were all taken from here.
8375 \layout Standard
8375 \layout Standard
8376
8376
8377 When I found out (see sec.
8377 When I found out (see sec.
8378
8378
8379 \begin_inset LatexCommand \ref{figgins}
8379 \begin_inset LatexCommand \ref{figgins}
8380
8380
8381 \end_inset
8381 \end_inset
8382
8382
8383 ) about IPP and LazyPython I tried to join all three into a unified system.
8383 ) about IPP and LazyPython I tried to join all three into a unified system.
8384 I thought this could provide a very nice working environment, both for
8384 I thought this could provide a very nice working environment, both for
8385 regular programming and scientific computing: shell-like features, IDL/Matlab
8385 regular programming and scientific computing: shell-like features, IDL/Matlab
8386 numerics, Mathematica-type prompt history and great object introspection
8386 numerics, Mathematica-type prompt history and great object introspection
8387 and help facilities.
8387 and help facilities.
8388 I think it worked reasonably well, though it was a lot more work than I
8388 I think it worked reasonably well, though it was a lot more work than I
8389 had initially planned.
8389 had initially planned.
8390 \layout Subsection
8390 \layout Subsection
8391
8391
8392 Current status
8392 Current status
8393 \layout Standard
8393 \layout Standard
8394
8394
8395 The above listed features work, and quite well for the most part.
8395 The above listed features work, and quite well for the most part.
8396 But until a major internal restructuring is done (see below), only bug
8396 But until a major internal restructuring is done (see below), only bug
8397 fixing will be done, no other features will be added (unless very minor
8397 fixing will be done, no other features will be added (unless very minor
8398 and well localized in the cleaner parts of the code).
8398 and well localized in the cleaner parts of the code).
8399 \layout Standard
8399 \layout Standard
8400
8400
8401 IPython consists of some 12000 lines of pure python code, of which roughly
8401 IPython consists of some 12000 lines of pure python code, of which roughly
8402 50% are fairly clean.
8402 50% are fairly clean.
8403 The other 50% are fragile, messy code which needs a massive restructuring
8403 The other 50% are fragile, messy code which needs a massive restructuring
8404 before any further major work is done.
8404 before any further major work is done.
8405 Even the messy code is fairly well documented though, and most of the problems
8405 Even the messy code is fairly well documented though, and most of the problems
8406 in the (non-existent) class design are well pointed to by a PyChecker run.
8406 in the (non-existent) class design are well pointed to by a PyChecker run.
8407 So the rewriting work isn't that bad, it will just be time-consuming.
8407 So the rewriting work isn't that bad, it will just be time-consuming.
8408 \layout Subsection
8408 \layout Subsection
8409
8409
8410 Future
8410 Future
8411 \layout Standard
8411 \layout Standard
8412
8412
8413 See the separate
8413 See the separate
8414 \family typewriter
8414 \family typewriter
8415 new_design
8415 new_design
8416 \family default
8416 \family default
8417 document for details.
8417 document for details.
8418 Ultimately, I would like to see IPython become part of the standard Python
8418 Ultimately, I would like to see IPython become part of the standard Python
8419 distribution as a `big brother with batteries' to the standard Python interacti
8419 distribution as a `big brother with batteries' to the standard Python interacti
8420 ve interpreter.
8420 ve interpreter.
8421 But that will never happen with the current state of the code, so all contribut
8421 But that will never happen with the current state of the code, so all contribut
8422 ions are welcome.
8422 ions are welcome.
8423 \layout Section
8423 \layout Section
8424
8424
8425 License
8425 License
8426 \layout Standard
8426 \layout Standard
8427
8427
8428 IPython is released under the terms of the BSD license, whose general form
8428 IPython is released under the terms of the BSD license, whose general form
8429 can be found at:
8429 can be found at:
8430 \begin_inset LatexCommand \htmlurl{http://www.opensource.org/licenses/bsd-license.php}
8430 \begin_inset LatexCommand \htmlurl{http://www.opensource.org/licenses/bsd-license.php}
8431
8431
8432 \end_inset
8432 \end_inset
8433
8433
8434 .
8434 .
8435 The full text of the IPython license is reproduced below:
8435 The full text of the IPython license is reproduced below:
8436 \layout Quote
8436 \layout Quote
8437
8437
8438
8438
8439 \family typewriter
8439 \family typewriter
8440 \size small
8440 \size small
8441 IPython is released under a BSD-type license.
8441 IPython is released under a BSD-type license.
8442 \layout Quote
8442 \layout Quote
8443
8443
8444
8444
8445 \family typewriter
8445 \family typewriter
8446 \size small
8446 \size small
8447 Copyright (c) 2001, 2002, 2003, 2004 Fernando Perez <fperez@colorado.edu>.
8447 Copyright (c) 2001, 2002, 2003, 2004 Fernando Perez <fperez@colorado.edu>.
8448 \layout Quote
8448 \layout Quote
8449
8449
8450
8450
8451 \family typewriter
8451 \family typewriter
8452 \size small
8452 \size small
8453 Copyright (c) 2001 Janko Hauser <jhauser@zscout.de> and
8453 Copyright (c) 2001 Janko Hauser <jhauser@zscout.de> and
8454 \newline
8454 \newline
8455 Nathaniel Gray <n8gray@caltech.edu>.
8455 Nathaniel Gray <n8gray@caltech.edu>.
8456 \layout Quote
8456 \layout Quote
8457
8457
8458
8458
8459 \family typewriter
8459 \family typewriter
8460 \size small
8460 \size small
8461 All rights reserved.
8461 All rights reserved.
8462 \layout Quote
8462 \layout Quote
8463
8463
8464
8464
8465 \family typewriter
8465 \family typewriter
8466 \size small
8466 \size small
8467 Redistribution and use in source and binary forms, with or without modification,
8467 Redistribution and use in source and binary forms, with or without modification,
8468 are permitted provided that the following conditions are met:
8468 are permitted provided that the following conditions are met:
8469 \layout Quote
8469 \layout Quote
8470
8470
8471
8471
8472 \family typewriter
8472 \family typewriter
8473 \size small
8473 \size small
8474 a.
8474 a.
8475 Redistributions of source code must retain the above copyright notice,
8475 Redistributions of source code must retain the above copyright notice,
8476 this list of conditions and the following disclaimer.
8476 this list of conditions and the following disclaimer.
8477 \layout Quote
8477 \layout Quote
8478
8478
8479
8479
8480 \family typewriter
8480 \family typewriter
8481 \size small
8481 \size small
8482 b.
8482 b.
8483 Redistributions in binary form must reproduce the above copyright notice,
8483 Redistributions in binary form must reproduce the above copyright notice,
8484 this list of conditions and the following disclaimer in the documentation
8484 this list of conditions and the following disclaimer in the documentation
8485 and/or other materials provided with the distribution.
8485 and/or other materials provided with the distribution.
8486 \layout Quote
8486 \layout Quote
8487
8487
8488
8488
8489 \family typewriter
8489 \family typewriter
8490 \size small
8490 \size small
8491 c.
8491 c.
8492 Neither the name of the copyright holders nor the names of any contributors
8492 Neither the name of the copyright holders nor the names of any contributors
8493 to this software may be used to endorse or promote products derived from
8493 to this software may be used to endorse or promote products derived from
8494 this software without specific prior written permission.
8494 this software without specific prior written permission.
8495 \layout Quote
8495 \layout Quote
8496
8496
8497
8497
8498 \family typewriter
8498 \family typewriter
8499 \size small
8499 \size small
8500 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
8500 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
8501 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
8501 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
8502 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
8502 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
8503 PURPOSE ARE DISCLAIMED.
8503 PURPOSE ARE DISCLAIMED.
8504 IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
8504 IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
8505 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
8505 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
8506 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
8506 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
8507 USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
8507 USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
8508 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
8508 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
8509 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
8509 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
8510 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8510 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8511
8511
8512 \layout Standard
8512 \layout Standard
8513
8513
8514 Individual authors are the holders of the copyright for their code and are
8514 Individual authors are the holders of the copyright for their code and are
8515 listed in each file.
8515 listed in each file.
8516 \layout Standard
8516 \layout Standard
8517
8517
8518 Some files (
8518 Some files (
8519 \family typewriter
8519 \family typewriter
8520 DPyGetOpt.py
8520 DPyGetOpt.py
8521 \family default
8521 \family default
8522 , for example) may be licensed under different conditions.
8522 , for example) may be licensed under different conditions.
8523 Ultimately each file indicates clearly the conditions under which its author/au
8523 Ultimately each file indicates clearly the conditions under which its author/au
8524 thors have decided to publish the code.
8524 thors have decided to publish the code.
8525 \layout Standard
8525 \layout Standard
8526
8526
8527 Versions of IPython up to and including 0.6.3 were released under the GNU
8527 Versions of IPython up to and including 0.6.3 were released under the GNU
8528 Lesser General Public License (LGPL), available at
8528 Lesser General Public License (LGPL), available at
8529 \begin_inset LatexCommand \htmlurl{http://www.gnu.org/copyleft/lesser.html}
8529 \begin_inset LatexCommand \htmlurl{http://www.gnu.org/copyleft/lesser.html}
8530
8530
8531 \end_inset
8531 \end_inset
8532
8532
8533 .
8533 .
8534 \layout Section
8534 \layout Section
8535
8535
8536
8536
8537 \begin_inset LatexCommand \label{sec:credits}
8537 \begin_inset LatexCommand \label{sec:credits}
8538
8538
8539 \end_inset
8539 \end_inset
8540
8540
8541 Credits
8541 Credits
8542 \layout Standard
8542 \layout Standard
8543
8543
8544 IPython is mainly developed by Fernando PΓ©rez
8544 IPython is mainly developed by Fernando PΓ©rez
8545 \family typewriter
8545 \family typewriter
8546 <fperez@colorado.edu>
8546 <fperez@colorado.edu>
8547 \family default
8547 \family default
8548 , but the project was born from mixing in Fernando's code with the IPP project
8548 , but the project was born from mixing in Fernando's code with the IPP project
8549 by Janko Hauser
8549 by Janko Hauser
8550 \family typewriter
8550 \family typewriter
8551 <jhauser-AT-zscout.de>
8551 <jhauser-AT-zscout.de>
8552 \family default
8552 \family default
8553 and LazyPython by Nathan Gray
8553 and LazyPython by Nathan Gray
8554 \family typewriter
8554 \family typewriter
8555 <n8gray-AT-caltech.edu>
8555 <n8gray-AT-caltech.edu>
8556 \family default
8556 \family default
8557 .
8557 .
8558 For all IPython-related requests, please contact Fernando.
8558 For all IPython-related requests, please contact Fernando.
8559
8559
8560 \layout Standard
8560 \layout Standard
8561
8561
8562 As of late 2005, the following developers have joined the core team:
8562 As of late 2005, the following developers have joined the core team:
8563 \layout List
8563 \layout List
8564 \labelwidthstring 00.00.0000
8564 \labelwidthstring 00.00.0000
8565
8565
8566 Robert\SpecialChar ~
8566 Robert\SpecialChar ~
8567 Kern
8567 Kern
8568 \family typewriter
8568 \family typewriter
8569 <rkern-AT-enthought.com>
8569 <rkern-AT-enthought.com>
8570 \family default
8570 \family default
8571 : co-mentored the 2005 Google Summer of Code project to develop python interacti
8571 : co-mentored the 2005 Google Summer of Code project to develop python interacti
8572 ve notebooks (XML documents) and graphical interface.
8572 ve notebooks (XML documents) and graphical interface.
8573 This project was awarded to the students Tzanko Matev
8573 This project was awarded to the students Tzanko Matev
8574 \family typewriter
8574 \family typewriter
8575 <tsanko-AT-gmail.com>
8575 <tsanko-AT-gmail.com>
8576 \family default
8576 \family default
8577 and Toni Alatalo
8577 and Toni Alatalo
8578 \family typewriter
8578 \family typewriter
8579 <antont-AT-an.org>
8579 <antont-AT-an.org>
8580 \layout List
8580 \layout List
8581 \labelwidthstring 00.00.0000
8581 \labelwidthstring 00.00.0000
8582
8582
8583 Brian\SpecialChar ~
8583 Brian\SpecialChar ~
8584 Granger
8584 Granger
8585 \family typewriter
8585 \family typewriter
8586 <bgranger-AT-scu.edu>
8586 <bgranger-AT-scu.edu>
8587 \family default
8587 \family default
8588 : extending IPython to allow support for interactive parallel computing.
8588 : extending IPython to allow support for interactive parallel computing.
8589 \layout Standard
8589 \layout Standard
8590
8590
8591 User or development help should be requested via the IPython mailing lists:
8591 User or development help should be requested via the IPython mailing lists:
8592 \layout Description
8592 \layout Description
8593
8593
8594 User\SpecialChar ~
8594 User\SpecialChar ~
8595 list:
8595 list:
8596 \begin_inset LatexCommand \htmlurl{http://scipy.net/mailman/listinfo/ipython-user}
8596 \begin_inset LatexCommand \htmlurl{http://scipy.net/mailman/listinfo/ipython-user}
8597
8597
8598 \end_inset
8598 \end_inset
8599
8599
8600
8600
8601 \layout Description
8601 \layout Description
8602
8602
8603 Developer's\SpecialChar ~
8603 Developer's\SpecialChar ~
8604 list:
8604 list:
8605 \begin_inset LatexCommand \htmlurl{http://scipy.net/mailman/listinfo/ipython-dev}
8605 \begin_inset LatexCommand \htmlurl{http://scipy.net/mailman/listinfo/ipython-dev}
8606
8606
8607 \end_inset
8607 \end_inset
8608
8608
8609
8609
8610 \layout Standard
8610 \layout Standard
8611
8611
8612 The IPython project is also very grateful to
8612 The IPython project is also very grateful to
8613 \begin_inset Foot
8613 \begin_inset Foot
8614 collapsed true
8614 collapsed true
8615
8615
8616 \layout Standard
8616 \layout Standard
8617
8617
8618 I've mangled email addresses to reduce spam, since the IPython manuals can
8618 I've mangled email addresses to reduce spam, since the IPython manuals can
8619 be accessed online.
8619 be accessed online.
8620 \end_inset
8620 \end_inset
8621
8621
8622 :
8622 :
8623 \layout Standard
8623 \layout Standard
8624
8624
8625 Bill Bumgarner
8625 Bill Bumgarner
8626 \family typewriter
8626 \family typewriter
8627 <bbum-AT-friday.com>
8627 <bbum-AT-friday.com>
8628 \family default
8628 \family default
8629 : for providing the DPyGetOpt module which gives very powerful and convenient
8629 : for providing the DPyGetOpt module which gives very powerful and convenient
8630 handling of command-line options (light years ahead of what Python 2.1.1's
8630 handling of command-line options (light years ahead of what Python 2.1.1's
8631 getopt module does).
8631 getopt module does).
8632 \layout Standard
8632 \layout Standard
8633
8633
8634 Ka-Ping Yee
8634 Ka-Ping Yee
8635 \family typewriter
8635 \family typewriter
8636 <ping-AT-lfw.org>
8636 <ping-AT-lfw.org>
8637 \family default
8637 \family default
8638 : for providing the Itpl module for convenient and powerful string interpolation
8638 : for providing the Itpl module for convenient and powerful string interpolation
8639 with a much nicer syntax than formatting through the '%' operator.
8639 with a much nicer syntax than formatting through the '%' operator.
8640 \layout Standard
8640 \layout Standard
8641
8641
8642 Arnd BΓ€cker
8642 Arnd BΓ€cker
8643 \family typewriter
8643 \family typewriter
8644 <baecker-AT-physik.tu-dresden.de>
8644 <baecker-AT-physik.tu-dresden.de>
8645 \family default
8645 \family default
8646 : for his many very useful suggestions and comments, and lots of help with
8646 : for his many very useful suggestions and comments, and lots of help with
8647 testing and documentation checking.
8647 testing and documentation checking.
8648 Many of IPython's newer features are a result of discussions with him (bugs
8648 Many of IPython's newer features are a result of discussions with him (bugs
8649 are still my fault, not his).
8649 are still my fault, not his).
8650 \layout Standard
8650 \layout Standard
8651
8651
8652 Obviously Guido van\SpecialChar ~
8652 Obviously Guido van\SpecialChar ~
8653 Rossum and the whole Python development team, that goes
8653 Rossum and the whole Python development team, that goes
8654 without saying.
8654 without saying.
8655 \layout Standard
8655 \layout Standard
8656
8656
8657 IPython's website is generously hosted at
8657 IPython's website is generously hosted at
8658 \begin_inset LatexCommand \htmlurl{http://ipython.scipy.org}
8658 \begin_inset LatexCommand \htmlurl{http://ipython.scipy.org}
8659
8659
8660 \end_inset
8660 \end_inset
8661
8661
8662 by Enthought (
8662 by Enthought (
8663 \begin_inset LatexCommand \htmlurl{http://www.enthought.com}
8663 \begin_inset LatexCommand \htmlurl{http://www.enthought.com}
8664
8664
8665 \end_inset
8665 \end_inset
8666
8666
8667 ).
8667 ).
8668 I am very grateful to them and all of the SciPy team for their contribution.
8668 I am very grateful to them and all of the SciPy team for their contribution.
8669 \layout Standard
8669 \layout Standard
8670
8670
8671
8671
8672 \begin_inset LatexCommand \label{figgins}
8672 \begin_inset LatexCommand \label{figgins}
8673
8673
8674 \end_inset
8674 \end_inset
8675
8675
8676 Fernando would also like to thank Stephen Figgins
8676 Fernando would also like to thank Stephen Figgins
8677 \family typewriter
8677 \family typewriter
8678 <fig-AT-monitor.net>
8678 <fig-AT-monitor.net>
8679 \family default
8679 \family default
8680 , an O'Reilly Python editor.
8680 , an O'Reilly Python editor.
8681 His Oct/11/2001 article about IPP and LazyPython, was what got this project
8681 His Oct/11/2001 article about IPP and LazyPython, was what got this project
8682 started.
8682 started.
8683 You can read it at:
8683 You can read it at:
8684 \begin_inset LatexCommand \htmlurl{http://www.onlamp.com/pub/a/python/2001/10/11/pythonnews.html}
8684 \begin_inset LatexCommand \htmlurl{http://www.onlamp.com/pub/a/python/2001/10/11/pythonnews.html}
8685
8685
8686 \end_inset
8686 \end_inset
8687
8687
8688 .
8688 .
8689 \layout Standard
8689 \layout Standard
8690
8690
8691 And last but not least, all the kind IPython users who have emailed new
8691 And last but not least, all the kind IPython users who have emailed new
8692 code, bug reports, fixes, comments and ideas.
8692 code, bug reports, fixes, comments and ideas.
8693 A brief list follows, please let me know if I have ommitted your name by
8693 A brief list follows, please let me know if I have ommitted your name by
8694 accident:
8694 accident:
8695 \layout List
8695 \layout List
8696 \labelwidthstring 00.00.0000
8696 \labelwidthstring 00.00.0000
8697
8697
8698 Jack\SpecialChar ~
8698 Jack\SpecialChar ~
8699 Moffit
8699 Moffit
8700 \family typewriter
8700 \family typewriter
8701 <jack-AT-xiph.org>
8701 <jack-AT-xiph.org>
8702 \family default
8702 \family default
8703 Bug fixes, including the infamous color problem.
8703 Bug fixes, including the infamous color problem.
8704 This bug alone caused many lost hours and frustration, many thanks to him
8704 This bug alone caused many lost hours and frustration, many thanks to him
8705 for the fix.
8705 for the fix.
8706 I've always been a fan of Ogg & friends, now I have one more reason to
8706 I've always been a fan of Ogg & friends, now I have one more reason to
8707 like these folks.
8707 like these folks.
8708 \newline
8708 \newline
8709 Jack is also contributing with Debian packaging and many other things.
8709 Jack is also contributing with Debian packaging and many other things.
8710 \layout List
8710 \layout List
8711 \labelwidthstring 00.00.0000
8711 \labelwidthstring 00.00.0000
8712
8712
8713 Alexander\SpecialChar ~
8713 Alexander\SpecialChar ~
8714 Schmolck
8714 Schmolck
8715 \family typewriter
8715 \family typewriter
8716 <a.schmolck-AT-gmx.net>
8716 <a.schmolck-AT-gmx.net>
8717 \family default
8717 \family default
8718 Emacs work, bug reports, bug fixes, ideas, lots more.
8718 Emacs work, bug reports, bug fixes, ideas, lots more.
8719 The ipython.el mode for (X)Emacs is Alex's code, providing full support
8719 The ipython.el mode for (X)Emacs is Alex's code, providing full support
8720 for IPython under (X)Emacs.
8720 for IPython under (X)Emacs.
8721 \layout List
8721 \layout List
8722 \labelwidthstring 00.00.0000
8722 \labelwidthstring 00.00.0000
8723
8723
8724 Andrea\SpecialChar ~
8724 Andrea\SpecialChar ~
8725 Riciputi
8725 Riciputi
8726 \family typewriter
8726 \family typewriter
8727 <andrea.riciputi-AT-libero.it>
8727 <andrea.riciputi-AT-libero.it>
8728 \family default
8728 \family default
8729 Mac OSX information, Fink package management.
8729 Mac OSX information, Fink package management.
8730 \layout List
8730 \layout List
8731 \labelwidthstring 00.00.0000
8731 \labelwidthstring 00.00.0000
8732
8732
8733 Gary\SpecialChar ~
8733 Gary\SpecialChar ~
8734 Bishop
8734 Bishop
8735 \family typewriter
8735 \family typewriter
8736 <gb-AT-cs.unc.edu>
8736 <gb-AT-cs.unc.edu>
8737 \family default
8737 \family default
8738 Bug reports, and patches to work around the exception handling idiosyncracies
8738 Bug reports, and patches to work around the exception handling idiosyncracies
8739 of WxPython.
8739 of WxPython.
8740 Readline and color support for Windows.
8740 Readline and color support for Windows.
8741 \layout List
8741 \layout List
8742 \labelwidthstring 00.00.0000
8742 \labelwidthstring 00.00.0000
8743
8743
8744 Jeffrey\SpecialChar ~
8744 Jeffrey\SpecialChar ~
8745 Collins
8745 Collins
8746 \family typewriter
8746 \family typewriter
8747 <Jeff.Collins-AT-vexcel.com>
8747 <Jeff.Collins-AT-vexcel.com>
8748 \family default
8748 \family default
8749 Bug reports.
8749 Bug reports.
8750 Much improved readline support, including fixes for Python 2.3.
8750 Much improved readline support, including fixes for Python 2.3.
8751 \layout List
8751 \layout List
8752 \labelwidthstring 00.00.0000
8752 \labelwidthstring 00.00.0000
8753
8753
8754 Dryice\SpecialChar ~
8754 Dryice\SpecialChar ~
8755 Liu
8755 Liu
8756 \family typewriter
8756 \family typewriter
8757 <dryice-AT-liu.com.cn>
8757 <dryice-AT-liu.com.cn>
8758 \family default
8758 \family default
8759 FreeBSD port.
8759 FreeBSD port.
8760 \layout List
8760 \layout List
8761 \labelwidthstring 00.00.0000
8761 \labelwidthstring 00.00.0000
8762
8762
8763 Mike\SpecialChar ~
8763 Mike\SpecialChar ~
8764 Heeter
8764 Heeter
8765 \family typewriter
8765 \family typewriter
8766 <korora-AT-SDF.LONESTAR.ORG>
8766 <korora-AT-SDF.LONESTAR.ORG>
8767 \layout List
8767 \layout List
8768 \labelwidthstring 00.00.0000
8768 \labelwidthstring 00.00.0000
8769
8769
8770 Christopher\SpecialChar ~
8770 Christopher\SpecialChar ~
8771 Hart
8771 Hart
8772 \family typewriter
8772 \family typewriter
8773 <hart-AT-caltech.edu>
8773 <hart-AT-caltech.edu>
8774 \family default
8774 \family default
8775 PDB integration.
8775 PDB integration.
8776 \layout List
8776 \layout List
8777 \labelwidthstring 00.00.0000
8777 \labelwidthstring 00.00.0000
8778
8778
8779 Milan\SpecialChar ~
8779 Milan\SpecialChar ~
8780 Zamazal
8780 Zamazal
8781 \family typewriter
8781 \family typewriter
8782 <pdm-AT-zamazal.org>
8782 <pdm-AT-zamazal.org>
8783 \family default
8783 \family default
8784 Emacs info.
8784 Emacs info.
8785 \layout List
8785 \layout List
8786 \labelwidthstring 00.00.0000
8786 \labelwidthstring 00.00.0000
8787
8787
8788 Philip\SpecialChar ~
8788 Philip\SpecialChar ~
8789 Hisley
8789 Hisley
8790 \family typewriter
8790 \family typewriter
8791 <compsys-AT-starpower.net>
8791 <compsys-AT-starpower.net>
8792 \layout List
8792 \layout List
8793 \labelwidthstring 00.00.0000
8793 \labelwidthstring 00.00.0000
8794
8794
8795 Holger\SpecialChar ~
8795 Holger\SpecialChar ~
8796 Krekel
8796 Krekel
8797 \family typewriter
8797 \family typewriter
8798 <pyth-AT-devel.trillke.net>
8798 <pyth-AT-devel.trillke.net>
8799 \family default
8799 \family default
8800 Tab completion, lots more.
8800 Tab completion, lots more.
8801 \layout List
8801 \layout List
8802 \labelwidthstring 00.00.0000
8802 \labelwidthstring 00.00.0000
8803
8803
8804 Robin\SpecialChar ~
8804 Robin\SpecialChar ~
8805 Siebler
8805 Siebler
8806 \family typewriter
8806 \family typewriter
8807 <robinsiebler-AT-starband.net>
8807 <robinsiebler-AT-starband.net>
8808 \layout List
8808 \layout List
8809 \labelwidthstring 00.00.0000
8809 \labelwidthstring 00.00.0000
8810
8810
8811 Ralf\SpecialChar ~
8811 Ralf\SpecialChar ~
8812 Ahlbrink
8812 Ahlbrink
8813 \family typewriter
8813 \family typewriter
8814 <ralf_ahlbrink-AT-web.de>
8814 <ralf_ahlbrink-AT-web.de>
8815 \layout List
8815 \layout List
8816 \labelwidthstring 00.00.0000
8816 \labelwidthstring 00.00.0000
8817
8817
8818 Thorsten\SpecialChar ~
8818 Thorsten\SpecialChar ~
8819 Kampe
8819 Kampe
8820 \family typewriter
8820 \family typewriter
8821 <thorsten-AT-thorstenkampe.de>
8821 <thorsten-AT-thorstenkampe.de>
8822 \layout List
8822 \layout List
8823 \labelwidthstring 00.00.0000
8823 \labelwidthstring 00.00.0000
8824
8824
8825 Fredrik\SpecialChar ~
8825 Fredrik\SpecialChar ~
8826 Kant
8826 Kant
8827 \family typewriter
8827 \family typewriter
8828 <fredrik.kant-AT-front.com>
8828 <fredrik.kant-AT-front.com>
8829 \family default
8829 \family default
8830 Windows setup.
8830 Windows setup.
8831 \layout List
8831 \layout List
8832 \labelwidthstring 00.00.0000
8832 \labelwidthstring 00.00.0000
8833
8833
8834 Syver\SpecialChar ~
8834 Syver\SpecialChar ~
8835 Enstad
8835 Enstad
8836 \family typewriter
8836 \family typewriter
8837 <syver-en-AT-online.no>
8837 <syver-en-AT-online.no>
8838 \family default
8838 \family default
8839 Windows setup.
8839 Windows setup.
8840 \layout List
8840 \layout List
8841 \labelwidthstring 00.00.0000
8841 \labelwidthstring 00.00.0000
8842
8842
8843 Richard
8843 Richard
8844 \family typewriter
8844 \family typewriter
8845 <rxe-AT-renre-europe.com>
8845 <rxe-AT-renre-europe.com>
8846 \family default
8846 \family default
8847 Global embedding.
8847 Global embedding.
8848 \layout List
8848 \layout List
8849 \labelwidthstring 00.00.0000
8849 \labelwidthstring 00.00.0000
8850
8850
8851 Hayden\SpecialChar ~
8851 Hayden\SpecialChar ~
8852 Callow
8852 Callow
8853 \family typewriter
8853 \family typewriter
8854 <h.callow-AT-elec.canterbury.ac.nz>
8854 <h.callow-AT-elec.canterbury.ac.nz>
8855 \family default
8855 \family default
8856 Gnuplot.py 1.6 compatibility.
8856 Gnuplot.py 1.6 compatibility.
8857 \layout List
8857 \layout List
8858 \labelwidthstring 00.00.0000
8858 \labelwidthstring 00.00.0000
8859
8859
8860 Leonardo\SpecialChar ~
8860 Leonardo\SpecialChar ~
8861 Santagada
8861 Santagada
8862 \family typewriter
8862 \family typewriter
8863 <retype-AT-terra.com.br>
8863 <retype-AT-terra.com.br>
8864 \family default
8864 \family default
8865 Fixes for Windows installation.
8865 Fixes for Windows installation.
8866 \layout List
8866 \layout List
8867 \labelwidthstring 00.00.0000
8867 \labelwidthstring 00.00.0000
8868
8868
8869 Christopher\SpecialChar ~
8869 Christopher\SpecialChar ~
8870 Armstrong
8870 Armstrong
8871 \family typewriter
8871 \family typewriter
8872 <radix-AT-twistedmatrix.com>
8872 <radix-AT-twistedmatrix.com>
8873 \family default
8873 \family default
8874 Bugfixes.
8874 Bugfixes.
8875 \layout List
8875 \layout List
8876 \labelwidthstring 00.00.0000
8876 \labelwidthstring 00.00.0000
8877
8877
8878 Francois\SpecialChar ~
8878 Francois\SpecialChar ~
8879 Pinard
8879 Pinard
8880 \family typewriter
8880 \family typewriter
8881 <pinard-AT-iro.umontreal.ca>
8881 <pinard-AT-iro.umontreal.ca>
8882 \family default
8882 \family default
8883 Code and documentation fixes.
8883 Code and documentation fixes.
8884 \layout List
8884 \layout List
8885 \labelwidthstring 00.00.0000
8885 \labelwidthstring 00.00.0000
8886
8886
8887 Cory\SpecialChar ~
8887 Cory\SpecialChar ~
8888 Dodt
8888 Dodt
8889 \family typewriter
8889 \family typewriter
8890 <cdodt-AT-fcoe.k12.ca.us>
8890 <cdodt-AT-fcoe.k12.ca.us>
8891 \family default
8891 \family default
8892 Bug reports and Windows ideas.
8892 Bug reports and Windows ideas.
8893 Patches for Windows installer.
8893 Patches for Windows installer.
8894 \layout List
8894 \layout List
8895 \labelwidthstring 00.00.0000
8895 \labelwidthstring 00.00.0000
8896
8896
8897 Olivier\SpecialChar ~
8897 Olivier\SpecialChar ~
8898 Aubert
8898 Aubert
8899 \family typewriter
8899 \family typewriter
8900 <oaubert-AT-bat710.univ-lyon1.fr>
8900 <oaubert-AT-bat710.univ-lyon1.fr>
8901 \family default
8901 \family default
8902 New magics.
8902 New magics.
8903 \layout List
8903 \layout List
8904 \labelwidthstring 00.00.0000
8904 \labelwidthstring 00.00.0000
8905
8905
8906 King\SpecialChar ~
8906 King\SpecialChar ~
8907 C.\SpecialChar ~
8907 C.\SpecialChar ~
8908 Shu
8908 Shu
8909 \family typewriter
8909 \family typewriter
8910 <kingshu-AT-myrealbox.com>
8910 <kingshu-AT-myrealbox.com>
8911 \family default
8911 \family default
8912 Autoindent patch.
8912 Autoindent patch.
8913 \layout List
8913 \layout List
8914 \labelwidthstring 00.00.0000
8914 \labelwidthstring 00.00.0000
8915
8915
8916 Chris\SpecialChar ~
8916 Chris\SpecialChar ~
8917 Drexler
8917 Drexler
8918 \family typewriter
8918 \family typewriter
8919 <chris-AT-ac-drexler.de>
8919 <chris-AT-ac-drexler.de>
8920 \family default
8920 \family default
8921 Readline packages for Win32/CygWin.
8921 Readline packages for Win32/CygWin.
8922 \layout List
8922 \layout List
8923 \labelwidthstring 00.00.0000
8923 \labelwidthstring 00.00.0000
8924
8924
8925 Gustavo\SpecialChar ~
8925 Gustavo\SpecialChar ~
8926 CΓ³rdova\SpecialChar ~
8926 CΓ³rdova\SpecialChar ~
8927 Avila
8927 Avila
8928 \family typewriter
8928 \family typewriter
8929 <gcordova-AT-sismex.com>
8929 <gcordova-AT-sismex.com>
8930 \family default
8930 \family default
8931 EvalDict code for nice, lightweight string interpolation.
8931 EvalDict code for nice, lightweight string interpolation.
8932 \layout List
8932 \layout List
8933 \labelwidthstring 00.00.0000
8933 \labelwidthstring 00.00.0000
8934
8934
8935 Kasper\SpecialChar ~
8935 Kasper\SpecialChar ~
8936 Souren
8936 Souren
8937 \family typewriter
8937 \family typewriter
8938 <Kasper.Souren-AT-ircam.fr>
8938 <Kasper.Souren-AT-ircam.fr>
8939 \family default
8939 \family default
8940 Bug reports, ideas.
8940 Bug reports, ideas.
8941 \layout List
8941 \layout List
8942 \labelwidthstring 00.00.0000
8942 \labelwidthstring 00.00.0000
8943
8943
8944 Gever\SpecialChar ~
8944 Gever\SpecialChar ~
8945 Tulley
8945 Tulley
8946 \family typewriter
8946 \family typewriter
8947 <gever-AT-helium.com>
8947 <gever-AT-helium.com>
8948 \family default
8948 \family default
8949 Code contributions.
8949 Code contributions.
8950 \layout List
8950 \layout List
8951 \labelwidthstring 00.00.0000
8951 \labelwidthstring 00.00.0000
8952
8952
8953 Ralf\SpecialChar ~
8953 Ralf\SpecialChar ~
8954 Schmitt
8954 Schmitt
8955 \family typewriter
8955 \family typewriter
8956 <ralf-AT-brainbot.com>
8956 <ralf-AT-brainbot.com>
8957 \family default
8957 \family default
8958 Bug reports & fixes.
8958 Bug reports & fixes.
8959 \layout List
8959 \layout List
8960 \labelwidthstring 00.00.0000
8960 \labelwidthstring 00.00.0000
8961
8961
8962 Oliver\SpecialChar ~
8962 Oliver\SpecialChar ~
8963 Sander
8963 Sander
8964 \family typewriter
8964 \family typewriter
8965 <osander-AT-gmx.de>
8965 <osander-AT-gmx.de>
8966 \family default
8966 \family default
8967 Bug reports.
8967 Bug reports.
8968 \layout List
8968 \layout List
8969 \labelwidthstring 00.00.0000
8969 \labelwidthstring 00.00.0000
8970
8970
8971 Rod\SpecialChar ~
8971 Rod\SpecialChar ~
8972 Holland
8972 Holland
8973 \family typewriter
8973 \family typewriter
8974 <rhh-AT-structurelabs.com>
8974 <rhh-AT-structurelabs.com>
8975 \family default
8975 \family default
8976 Bug reports and fixes to logging module.
8976 Bug reports and fixes to logging module.
8977 \layout List
8977 \layout List
8978 \labelwidthstring 00.00.0000
8978 \labelwidthstring 00.00.0000
8979
8979
8980 Daniel\SpecialChar ~
8980 Daniel\SpecialChar ~
8981 'Dang'\SpecialChar ~
8981 'Dang'\SpecialChar ~
8982 Griffith
8982 Griffith
8983 \family typewriter
8983 \family typewriter
8984 <pythondev-dang-AT-lazytwinacres.net>
8984 <pythondev-dang-AT-lazytwinacres.net>
8985 \family default
8985 \family default
8986 Fixes, enhancement suggestions for system shell use.
8986 Fixes, enhancement suggestions for system shell use.
8987 \layout List
8987 \layout List
8988 \labelwidthstring 00.00.0000
8988 \labelwidthstring 00.00.0000
8989
8989
8990 Viktor\SpecialChar ~
8990 Viktor\SpecialChar ~
8991 Ransmayr
8991 Ransmayr
8992 \family typewriter
8992 \family typewriter
8993 <viktor.ransmayr-AT-t-online.de>
8993 <viktor.ransmayr-AT-t-online.de>
8994 \family default
8994 \family default
8995 Tests and reports on Windows installation issues.
8995 Tests and reports on Windows installation issues.
8996 Contributed a true Windows binary installer.
8996 Contributed a true Windows binary installer.
8997 \layout List
8997 \layout List
8998 \labelwidthstring 00.00.0000
8998 \labelwidthstring 00.00.0000
8999
8999
9000 Mike\SpecialChar ~
9000 Mike\SpecialChar ~
9001 Salib
9001 Salib
9002 \family typewriter
9002 \family typewriter
9003 <msalib-AT-mit.edu>
9003 <msalib-AT-mit.edu>
9004 \family default
9004 \family default
9005 Help fixing a subtle bug related to traceback printing.
9005 Help fixing a subtle bug related to traceback printing.
9006 \layout List
9006 \layout List
9007 \labelwidthstring 00.00.0000
9007 \labelwidthstring 00.00.0000
9008
9008
9009 W.J.\SpecialChar ~
9009 W.J.\SpecialChar ~
9010 van\SpecialChar ~
9010 van\SpecialChar ~
9011 der\SpecialChar ~
9011 der\SpecialChar ~
9012 Laan
9012 Laan
9013 \family typewriter
9013 \family typewriter
9014 <gnufnork-AT-hetdigitalegat.nl>
9014 <gnufnork-AT-hetdigitalegat.nl>
9015 \family default
9015 \family default
9016 Bash-like prompt specials.
9016 Bash-like prompt specials.
9017 \layout List
9017 \layout List
9018 \labelwidthstring 00.00.0000
9018 \labelwidthstring 00.00.0000
9019
9019
9020 Ville\SpecialChar ~
9020 Ville\SpecialChar ~
9021 Vainio
9021 Vainio
9022 \family typewriter
9022 \family typewriter
9023 <vivainio-AT-kolumbus.fi>
9023 <vivainio-AT-kolumbus.fi>
9024 \family default
9024 \family default
9025 Bugfixes and suggestions.
9025 Bugfixes and suggestions.
9026 Excellent patches for many new features.
9026 Excellent patches for many new features.
9027 \layout List
9027 \layout List
9028 \labelwidthstring 00.00.0000
9028 \labelwidthstring 00.00.0000
9029
9029
9030 Antoon\SpecialChar ~
9030 Antoon\SpecialChar ~
9031 Pardon
9031 Pardon
9032 \family typewriter
9032 \family typewriter
9033 <Antoon.Pardon-AT-rece.vub.ac.be>
9033 <Antoon.Pardon-AT-rece.vub.ac.be>
9034 \family default
9034 \family default
9035 Critical fix for the multithreaded IPython.
9035 Critical fix for the multithreaded IPython.
9036 \layout List
9036 \layout List
9037 \labelwidthstring 00.00.0000
9037 \labelwidthstring 00.00.0000
9038
9038
9039 John\SpecialChar ~
9039 John\SpecialChar ~
9040 Hunter
9040 Hunter
9041 \family typewriter
9041 \family typewriter
9042 <jdhunter-AT-nitace.bsd.uchicago.edu>
9042 <jdhunter-AT-nitace.bsd.uchicago.edu>
9043 \family default
9043 \family default
9044 Matplotlib author, helped with all the development of support for matplotlib
9044 Matplotlib author, helped with all the development of support for matplotlib
9045 in IPyhton, including making necessary changes to matplotlib itself.
9045 in IPyhton, including making necessary changes to matplotlib itself.
9046 \layout List
9046 \layout List
9047 \labelwidthstring 00.00.0000
9047 \labelwidthstring 00.00.0000
9048
9048
9049 Matthew\SpecialChar ~
9049 Matthew\SpecialChar ~
9050 Arnison
9050 Arnison
9051 \family typewriter
9051 \family typewriter
9052 <maffew-AT-cat.org.au>
9052 <maffew-AT-cat.org.au>
9053 \family default
9053 \family default
9054 Bug reports, `
9054 Bug reports, `
9055 \family typewriter
9055 \family typewriter
9056 %run -d
9056 %run -d
9057 \family default
9057 \family default
9058 ' idea.
9058 ' idea.
9059 \layout List
9059 \layout List
9060 \labelwidthstring 00.00.0000
9060 \labelwidthstring 00.00.0000
9061
9061
9062 Prabhu\SpecialChar ~
9062 Prabhu\SpecialChar ~
9063 Ramachandran
9063 Ramachandran
9064 \family typewriter
9064 \family typewriter
9065 <prabhu_r-AT-users.sourceforge.net>
9065 <prabhu_r-AT-users.sourceforge.net>
9066 \family default
9066 \family default
9067 Help with (X)Emacs support, threading patches, ideas...
9067 Help with (X)Emacs support, threading patches, ideas...
9068 \layout List
9068 \layout List
9069 \labelwidthstring 00.00.0000
9069 \labelwidthstring 00.00.0000
9070
9070
9071 Norbert\SpecialChar ~
9071 Norbert\SpecialChar ~
9072 Tretkowski
9072 Tretkowski
9073 \family typewriter
9073 \family typewriter
9074 <tretkowski-AT-inittab.de>
9074 <tretkowski-AT-inittab.de>
9075 \family default
9075 \family default
9076 help with Debian packaging and distribution.
9076 help with Debian packaging and distribution.
9077 \layout List
9077 \layout List
9078 \labelwidthstring 00.00.0000
9078 \labelwidthstring 00.00.0000
9079
9079
9080 George\SpecialChar ~
9080 George\SpecialChar ~
9081 Sakkis <
9081 Sakkis <
9082 \family typewriter
9082 \family typewriter
9083 gsakkis-AT-eden.rutgers.edu>
9083 gsakkis-AT-eden.rutgers.edu>
9084 \family default
9084 \family default
9085 New matcher for tab-completing named arguments of user-defined functions.
9085 New matcher for tab-completing named arguments of user-defined functions.
9086 \layout List
9086 \layout List
9087 \labelwidthstring 00.00.0000
9087 \labelwidthstring 00.00.0000
9088
9088
9089 JοΏ½rgen\SpecialChar ~
9089 JοΏ½rgen\SpecialChar ~
9090 Stenarson
9090 Stenarson
9091 \family typewriter
9091 \family typewriter
9092 <jorgen.stenarson-AT-bostream.nu>
9092 <jorgen.stenarson-AT-bostream.nu>
9093 \family default
9093 \family default
9094 Wildcard support implementation for searching namespaces.
9094 Wildcard support implementation for searching namespaces.
9095 \the_end
9095 \the_end
@@ -1,146 +1,149 b''
1 #!/usr/bin/env python
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
2 # -*- coding: utf-8 -*-
3 """Setup script for IPython.
3 """Setup script for IPython.
4
4
5 Under Posix environments it works like a typical setup.py script.
5 Under Posix environments it works like a typical setup.py script.
6 Under Windows, the command sdist is not supported, since IPython
6 Under Windows, the command sdist is not supported, since IPython
7 requires utilities, which are not available under Windows."""
7 requires utilities, which are not available under Windows."""
8
8
9 #*****************************************************************************
9 #*****************************************************************************
10 # Copyright (C) 2001-2005 Fernando Perez <fperez@colorado.edu>
10 # Copyright (C) 2001-2005 Fernando Perez <fperez@colorado.edu>
11 #
11 #
12 # Distributed under the terms of the BSD License. The full license is in
12 # Distributed under the terms of the BSD License. The full license is in
13 # the file COPYING, distributed as part of this software.
13 # the file COPYING, distributed as part of this software.
14 #*****************************************************************************
14 #*****************************************************************************
15
15
16 import sys, os
16 import sys, os
17 from glob import glob
17 from glob import glob
18 from setupext import install_data_ext
18 from setupext import install_data_ext
19 isfile = os.path.isfile
19 isfile = os.path.isfile
20
20
21 # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
21 # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
22 # update it when the contents of directories change.
22 # update it when the contents of directories change.
23 if os.path.exists('MANIFEST'): os.remove('MANIFEST')
23 if os.path.exists('MANIFEST'): os.remove('MANIFEST')
24
24
25 if os.name == 'posix':
25 if os.name == 'posix':
26 os_name = 'posix'
26 os_name = 'posix'
27 elif os.name in ['nt','dos']:
27 elif os.name in ['nt','dos']:
28 os_name = 'windows'
28 os_name = 'windows'
29 else:
29 else:
30 print 'Unsupported operating system:',os.name
30 print 'Unsupported operating system:',os.name
31 sys.exit(1)
31 sys.exit(1)
32
32
33 # Under Windows, 'sdist' is not supported, since it requires lyxport (and
33 # Under Windows, 'sdist' is not supported, since it requires lyxport (and
34 # hence lyx,perl,latex,pdflatex,latex2html,sh,...)
34 # hence lyx,perl,latex,pdflatex,latex2html,sh,...)
35 if os_name == 'windows' and sys.argv[1] == 'sdist':
35 if os_name == 'windows' and sys.argv[1] == 'sdist':
36 print 'The sdist command is not available under Windows. Exiting.'
36 print 'The sdist command is not available under Windows. Exiting.'
37 sys.exit(1)
37 sys.exit(1)
38
38
39 from distutils.core import setup
39 from distutils.core import setup
40
40
41 # update the manuals when building a source dist
41 # update the manuals when building a source dist
42 if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'):
42 if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'):
43 from IPython.genutils import target_update
43 from IPython.genutils import target_update
44 # list of things to be updated. Each entry is a triplet of args for
44 # list of things to be updated. Each entry is a triplet of args for
45 # target_update()
45 # target_update()
46 to_update = [('doc/magic.tex',
46 to_update = [('doc/magic.tex',
47 ['IPython/Magic.py'],
47 ['IPython/Magic.py'],
48 "cd doc && ./update_magic.sh" ),
48 "cd doc && ./update_magic.sh" ),
49
49
50 ('doc/manual.lyx',
50 ('doc/manual.lyx',
51 ['IPython/Release.py','doc/manual_base.lyx'],
51 ['IPython/Release.py','doc/manual_base.lyx'],
52 "cd doc && ./update_version.sh" ),
52 "cd doc && ./update_version.sh" ),
53
53
54 ('doc/manual/manual.html',
54 ('doc/manual/manual.html',
55 ['doc/manual.lyx',
55 ['doc/manual.lyx',
56 'doc/magic.tex',
56 'doc/magic.tex',
57 'doc/examples/example-gnuplot.py',
57 'doc/examples/example-gnuplot.py',
58 'doc/examples/example-magic.py',
58 'doc/examples/example-magic.py',
59 'doc/examples/example-embed.py',
59 'doc/examples/example-embed.py',
60 'doc/examples/example-embed-short.py',
60 'doc/examples/example-embed-short.py',
61 'IPython/UserConfig/ipythonrc',
61 'IPython/UserConfig/ipythonrc',
62 ],
62 ],
63 "cd doc && "
63 "cd doc && "
64 "lyxport -tt --leave --pdf "
64 "lyxport -tt --leave --pdf "
65 "--html -o '-noinfo -split +1 -local_icons' manual.lyx"),
65 "--html -o '-noinfo -split +1 -local_icons' manual.lyx"),
66
66
67 ('doc/new_design.pdf',
67 ('doc/new_design.pdf',
68 ['doc/new_design.lyx'],
68 ['doc/new_design.lyx'],
69 "cd doc && lyxport -tt --pdf new_design.lyx"),
69 "cd doc && lyxport -tt --pdf new_design.lyx"),
70
70
71 ('doc/ipython.1.gz',
71 ('doc/ipython.1.gz',
72 ['doc/ipython.1'],
72 ['doc/ipython.1'],
73 "cd doc && gzip -9c ipython.1 > ipython.1.gz"),
73 "cd doc && gzip -9c ipython.1 > ipython.1.gz"),
74
74
75 ('doc/pycolor.1.gz',
75 ('doc/pycolor.1.gz',
76 ['doc/pycolor.1'],
76 ['doc/pycolor.1'],
77 "cd doc && gzip -9c pycolor.1 > pycolor.1.gz"),
77 "cd doc && gzip -9c pycolor.1 > pycolor.1.gz"),
78 ]
78 ]
79 for target in to_update:
79 for target in to_update:
80 target_update(*target)
80 target_update(*target)
81
81
82 # Release.py contains version, authors, license, url, keywords, etc.
82 # Release.py contains version, authors, license, url, keywords, etc.
83 execfile(os.path.join('IPython','Release.py'))
83 execfile(os.path.join('IPython','Release.py'))
84
84
85 # A little utility we'll need below, since glob() does NOT allow you to do
85 # A little utility we'll need below, since glob() does NOT allow you to do
86 # exclusion on multiple endings!
86 # exclusion on multiple endings!
87 def file_doesnt_endwith(test,endings):
87 def file_doesnt_endwith(test,endings):
88 """Return true if test is a file and its name does NOT end with any
88 """Return true if test is a file and its name does NOT end with any
89 of the strings listed in endings."""
89 of the strings listed in endings."""
90 if not isfile(test):
90 if not isfile(test):
91 return False
91 return False
92 for e in endings:
92 for e in endings:
93 if test.endswith(e):
93 if test.endswith(e):
94 return False
94 return False
95 return True
95 return True
96
96
97 # I can't find how to make distutils create a nested dir. structure, so
97 # I can't find how to make distutils create a nested dir. structure, so
98 # in the meantime do it manually. Butt ugly.
98 # in the meantime do it manually. Butt ugly.
99 # Note that http://www.redbrick.dcu.ie/~noel/distutils.html, ex. 2/3, contain
100 # information on how to do this more cleanly once python 2.4 can be assumed.
101 # Thanks to Noel for the tip.
99 docdirbase = 'share/doc/ipython-%s' % version
102 docdirbase = 'share/doc/ipython-%s' % version
100 manpagebase = 'share/man/man1'
103 manpagebase = 'share/man/man1'
101
104
102 # We only need to exclude from this things NOT already excluded in the
105 # We only need to exclude from this things NOT already excluded in the
103 # MANIFEST.in file.
106 # MANIFEST.in file.
104 exclude = ('.sh','.1.gz')
107 exclude = ('.sh','.1.gz')
105 docfiles = filter(lambda f:file_doesnt_endwith(f,exclude),glob('doc/*'))
108 docfiles = filter(lambda f:file_doesnt_endwith(f,exclude),glob('doc/*'))
106
109
107 examfiles = filter(isfile, glob('doc/examples/*.py'))
110 examfiles = filter(isfile, glob('doc/examples/*.py'))
108 manfiles = filter(isfile, glob('doc/manual/*.html')) + \
111 manfiles = filter(isfile, glob('doc/manual/*.html')) + \
109 filter(isfile, glob('doc/manual/*.css')) + \
112 filter(isfile, glob('doc/manual/*.css')) + \
110 filter(isfile, glob('doc/manual/*.png'))
113 filter(isfile, glob('doc/manual/*.png'))
111 manpages = filter(isfile, glob('doc/*.1.gz'))
114 manpages = filter(isfile, glob('doc/*.1.gz'))
112 cfgfiles = filter(isfile, glob('IPython/UserConfig/*'))
115 cfgfiles = filter(isfile, glob('IPython/UserConfig/*'))
113 scriptfiles = filter(isfile, ['scripts/ipython','scripts/pycolor'])
116 scriptfiles = filter(isfile, ['scripts/ipython','scripts/pycolor'])
114
117
115 # Script to be run by the windows binary installer after the default setup
118 # Script to be run by the windows binary installer after the default setup
116 # routine, to add shortcuts and similar windows-only things. Windows
119 # routine, to add shortcuts and similar windows-only things. Windows
117 # post-install scripts MUST reside in the scripts/ dir, otherwise distutils
120 # post-install scripts MUST reside in the scripts/ dir, otherwise distutils
118 # doesn't find them.
121 # doesn't find them.
119 if 'bdist_wininst' in sys.argv:
122 if 'bdist_wininst' in sys.argv:
120 if len(sys.argv) > 2 and ('sdist' in sys.argv or 'bdist_rpm' in sys.argv):
123 if len(sys.argv) > 2 and ('sdist' in sys.argv or 'bdist_rpm' in sys.argv):
121 print >> sys.stderr,"ERROR: bdist_wininst must be run alone. Exiting."
124 print >> sys.stderr,"ERROR: bdist_wininst must be run alone. Exiting."
122 sys.exit(1)
125 sys.exit(1)
123 scriptfiles.append('scripts/ipython_win_post_install.py')
126 scriptfiles.append('scripts/ipython_win_post_install.py')
124
127
125 # Call the setup() routine which does most of the work
128 # Call the setup() routine which does most of the work
126 setup(name = name,
129 setup(name = name,
127 version = version,
130 version = version,
128 description = description,
131 description = description,
129 long_description = long_description,
132 long_description = long_description,
130 author = authors['Fernando'][0],
133 author = authors['Fernando'][0],
131 author_email = authors['Fernando'][1],
134 author_email = authors['Fernando'][1],
132 url = url,
135 url = url,
133 license = license,
136 license = license,
134 platforms = platforms,
137 platforms = platforms,
135 keywords = keywords,
138 keywords = keywords,
136 packages = ['IPython', 'IPython.Extensions'],
139 packages = ['IPython', 'IPython.Extensions'],
137 scripts = scriptfiles,
140 scripts = scriptfiles,
138 cmdclass = {'install_data': install_data_ext},
141 cmdclass = {'install_data': install_data_ext},
139 data_files = [('data', docdirbase, docfiles),
142 data_files = [('data', docdirbase, docfiles),
140 ('data', os.path.join(docdirbase, 'examples'),
143 ('data', os.path.join(docdirbase, 'examples'),
141 examfiles),
144 examfiles),
142 ('data', os.path.join(docdirbase, 'manual'),
145 ('data', os.path.join(docdirbase, 'manual'),
143 manfiles),
146 manfiles),
144 ('data', manpagebase, manpages),
147 ('data', manpagebase, manpages),
145 ('lib', 'IPython/UserConfig', cfgfiles)]
148 ('lib', 'IPython/UserConfig', cfgfiles)]
146 )
149 )
General Comments 0
You need to be logged in to leave comments. Login now