##// END OF EJS Templates
ipython.rst: cleanup, add sh profile docs, remove deprecated pysh stuff
Ville M. Vainio -
Show More
@@ -1,5029 +1,5022 b''
1 .. IPython documentation master file, created by sphinx-quickstart.py on Mon Mar 24 17:01:34 2008.
1 .. IPython documentation master file, created by sphinx-quickstart.py on Mon Mar 24 17:01:34 2008.
2 You can adapt this file completely to your liking, but it should at least
2 You can adapt this file completely to your liking, but it should at least
3 contain the root 'toctree' directive.
3 contain the root 'toctree' directive.
4
4
5 Welcome to IPython's documentation!
5 Welcome to IPython's documentation!
6 ===================================
6 ===================================
7
7
8 Contents:
8 Contents:
9
9
10 .. toctree::
10 .. toctree::
11 :maxdepth: 2
11 :maxdepth: 2
12
12
13 Indices and tables
13 Indices and tables
14 ==================
14 ==================
15
15
16 * :ref:`genindex`
16 * :ref:`genindex`
17 * :ref:`modindex`
17 * :ref:`modindex`
18 * :ref:`search`
18 * :ref:`search`
19
19
20 Overview
20 Overview
21 ========
21 ========
22
22
23 One of Python's most useful features is its interactive interpreter.
23 One of Python's most useful features is its interactive interpreter.
24 This system allows very fast testing of ideas without the overhead of
24 This system allows very fast testing of ideas without the overhead of
25 creating test files as is typical in most programming languages.
25 creating test files as is typical in most programming languages.
26 However, the interpreter supplied with the standard Python distribution
26 However, the interpreter supplied with the standard Python distribution
27 is somewhat limited for extended interactive use.
27 is somewhat limited for extended interactive use.
28
28
29 IPython is a free software project (released under the BSD license)
29 IPython is a free software project (released under the BSD license)
30 which tries to:
30 which tries to:
31
31
32 1. Provide an interactive shell superior to Python's default. IPython
32 1. Provide an interactive shell superior to Python's default. IPython
33 has many features for object introspection, system shell access,
33 has many features for object introspection, system shell access,
34 and its own special command system for adding functionality when
34 and its own special command system for adding functionality when
35 working interactively. It tries to be a very efficient environment
35 working interactively. It tries to be a very efficient environment
36 both for Python code development and for exploration of problems
36 both for Python code development and for exploration of problems
37 using Python objects (in situations like data analysis).
37 using Python objects (in situations like data analysis).
38 2. Serve as an embeddable, ready to use interpreter for your own
38 2. Serve as an embeddable, ready to use interpreter for your own
39 programs. IPython can be started with a single call from inside
39 programs. IPython can be started with a single call from inside
40 another program, providing access to the current namespace. This
40 another program, providing access to the current namespace. This
41 can be very useful both for debugging purposes and for situations
41 can be very useful both for debugging purposes and for situations
42 where a blend of batch-processing and interactive exploration are
42 where a blend of batch-processing and interactive exploration are
43 needed.
43 needed.
44 3. Offer a flexible framework which can be used as the base
44 3. Offer a flexible framework which can be used as the base
45 environment for other systems with Python as the underlying
45 environment for other systems with Python as the underlying
46 language. Specifically scientific environments like Mathematica,
46 language. Specifically scientific environments like Mathematica,
47 IDL and Matlab inspired its design, but similar ideas can be
47 IDL and Matlab inspired its design, but similar ideas can be
48 useful in many fields.
48 useful in many fields.
49 4. Allow interactive testing of threaded graphical toolkits. IPython
49 4. Allow interactive testing of threaded graphical toolkits. IPython
50 has support for interactive, non-blocking control of GTK, Qt and
50 has support for interactive, non-blocking control of GTK, Qt and
51 WX applications via special threading flags. The normal Python
51 WX applications via special threading flags. The normal Python
52 shell can only do this for Tkinter applications.
52 shell can only do this for Tkinter applications.
53
53
54
54
55 Main features
55 Main features
56
56
57 * Dynamic object introspection. One can access docstrings, function
57 * Dynamic object introspection. One can access docstrings, function
58 definition prototypes, source code, source files and other details
58 definition prototypes, source code, source files and other details
59 of any object accessible to the interpreter with a single
59 of any object accessible to the interpreter with a single
60 keystroke ('?', and using '??' provides additional detail).
60 keystroke ('?', and using '??' provides additional detail).
61 * Searching through modules and namespaces with '*' wildcards, both
61 * Searching through modules and namespaces with '*' wildcards, both
62 when using the '?' system and via the %psearch command.
62 when using the '?' system and via the %psearch command.
63 * Completion in the local namespace, by typing TAB at the prompt.
63 * Completion in the local namespace, by typing TAB at the prompt.
64 This works for keywords, methods, variables and files in the
64 This works for keywords, methods, variables and files in the
65 current directory. This is supported via the readline library, and
65 current directory. This is supported via the readline library, and
66 full access to configuring readline's behavior is provided.
66 full access to configuring readline's behavior is provided.
67 * Numbered input/output prompts with command history (persistent
67 * Numbered input/output prompts with command history (persistent
68 across sessions and tied to each profile), full searching in this
68 across sessions and tied to each profile), full searching in this
69 history and caching of all input and output.
69 history and caching of all input and output.
70 * User-extensible 'magic' commands. A set of commands prefixed with
70 * User-extensible 'magic' commands. A set of commands prefixed with
71 % is available for controlling IPython itself and provides
71 % is available for controlling IPython itself and provides
72 directory control, namespace information and many aliases to
72 directory control, namespace information and many aliases to
73 common system shell commands.
73 common system shell commands.
74 * Alias facility for defining your own system aliases.
74 * Alias facility for defining your own system aliases.
75 * Complete system shell access. Lines starting with ! are passed
75 * Complete system shell access. Lines starting with ! are passed
76 directly to the system shell, and using !! captures shell output
76 directly to the system shell, and using !! captures shell output
77 into python variables for further use.
77 into python variables for further use.
78 * Background execution of Python commands in a separate thread.
78 * Background execution of Python commands in a separate thread.
79 IPython has an internal job manager called jobs, and a
79 IPython has an internal job manager called jobs, and a
80 conveninence backgrounding magic function called %bg.
80 conveninence backgrounding magic function called %bg.
81 * The ability to expand python variables when calling the system
81 * The ability to expand python variables when calling the system
82 shell. In a shell command, any python variable prefixed with $ is
82 shell. In a shell command, any python variable prefixed with $ is
83 expanded. A double $$ allows passing a literal $ to the shell (for
83 expanded. A double $$ allows passing a literal $ to the shell (for
84 access to shell and environment variables like $PATH).
84 access to shell and environment variables like $PATH).
85 * Filesystem navigation, via a magic %cd command, along with a
85 * Filesystem navigation, via a magic %cd command, along with a
86 persistent bookmark system (using %bookmark) for fast access to
86 persistent bookmark system (using %bookmark) for fast access to
87 frequently visited directories.
87 frequently visited directories.
88 * A lightweight persistence framework via the %store command, which
88 * A lightweight persistence framework via the %store command, which
89 allows you to save arbitrary Python variables. These get restored
89 allows you to save arbitrary Python variables. These get restored
90 automatically when your session restarts.
90 automatically when your session restarts.
91 * Automatic indentation (optional) of code as you type (through the
91 * Automatic indentation (optional) of code as you type (through the
92 readline library).
92 readline library).
93 * Macro system for quickly re-executing multiple lines of previous
93 * Macro system for quickly re-executing multiple lines of previous
94 input with a single name. Macros can be stored persistently via
94 input with a single name. Macros can be stored persistently via
95 %store and edited via %edit.
95 %store and edited via %edit.
96 * Session logging (you can then later use these logs as code in your
96 * Session logging (you can then later use these logs as code in your
97 programs). Logs can optionally timestamp all input, and also store
97 programs). Logs can optionally timestamp all input, and also store
98 session output (marked as comments, so the log remains valid
98 session output (marked as comments, so the log remains valid
99 Python source code).
99 Python source code).
100 * Session restoring: logs can be replayed to restore a previous
100 * Session restoring: logs can be replayed to restore a previous
101 session to the state where you left it.
101 session to the state where you left it.
102 * Verbose and colored exception traceback printouts. Easier to parse
102 * Verbose and colored exception traceback printouts. Easier to parse
103 visually, and in verbose mode they produce a lot of useful
103 visually, and in verbose mode they produce a lot of useful
104 debugging information (basically a terminal version of the cgitb
104 debugging information (basically a terminal version of the cgitb
105 module).
105 module).
106 * Auto-parentheses: callable objects can be executed without
106 * Auto-parentheses: callable objects can be executed without
107 parentheses: 'sin 3' is automatically converted to 'sin(3)'.
107 parentheses: 'sin 3' is automatically converted to 'sin(3)'.
108 * Auto-quoting: using ',' or ';' as the first character forces
108 * Auto-quoting: using ',' or ';' as the first character forces
109 auto-quoting of the rest of the line: ',my_function a b' becomes
109 auto-quoting of the rest of the line: ',my_function a b' becomes
110 automatically 'my_function("a","b")', while ';my_function a b'
110 automatically 'my_function("a","b")', while ';my_function a b'
111 becomes 'my_function("a b")'.
111 becomes 'my_function("a b")'.
112 * Extensible input syntax. You can define filters that pre-process
112 * Extensible input syntax. You can define filters that pre-process
113 user input to simplify input in special situations. This allows
113 user input to simplify input in special situations. This allows
114 for example pasting multi-line code fragments which start with
114 for example pasting multi-line code fragments which start with
115 '>>>' or '...' such as those from other python sessions or the
115 '>>>' or '...' such as those from other python sessions or the
116 standard Python documentation.
116 standard Python documentation.
117 * Flexible configuration system. It uses a configuration file which
117 * Flexible configuration system. It uses a configuration file which
118 allows permanent setting of all command-line options, module
118 allows permanent setting of all command-line options, module
119 loading, code and file execution. The system allows recursive file
119 loading, code and file execution. The system allows recursive file
120 inclusion, so you can have a base file with defaults and layers
120 inclusion, so you can have a base file with defaults and layers
121 which load other customizations for particular projects.
121 which load other customizations for particular projects.
122 * Embeddable. You can call IPython as a python shell inside your own
122 * Embeddable. You can call IPython as a python shell inside your own
123 python programs. This can be used both for debugging code or for
123 python programs. This can be used both for debugging code or for
124 providing interactive abilities to your programs with knowledge
124 providing interactive abilities to your programs with knowledge
125 about the local namespaces (very useful in debugging and data
125 about the local namespaces (very useful in debugging and data
126 analysis situations).
126 analysis situations).
127 * Easy debugger access. You can set IPython to call up an enhanced
127 * Easy debugger access. You can set IPython to call up an enhanced
128 version of the Python debugger (pdb) every time there is an
128 version of the Python debugger (pdb) every time there is an
129 uncaught exception. This drops you inside the code which triggered
129 uncaught exception. This drops you inside the code which triggered
130 the exception with all the data live and it is possible to
130 the exception with all the data live and it is possible to
131 navigate the stack to rapidly isolate the source of a bug. The
131 navigate the stack to rapidly isolate the source of a bug. The
132 %run magic command -with the -d option- can run any script under
132 %run magic command -with the -d option- can run any script under
133 pdb's control, automatically setting initial breakpoints for you.
133 pdb's control, automatically setting initial breakpoints for you.
134 This version of pdb has IPython-specific improvements, including
134 This version of pdb has IPython-specific improvements, including
135 tab-completion and traceback coloring support.
135 tab-completion and traceback coloring support.
136 * Profiler support. You can run single statements (similar to
136 * Profiler support. You can run single statements (similar to
137 profile.run()) or complete programs under the profiler's control.
137 profile.run()) or complete programs under the profiler's control.
138 While this is possible with standard cProfile or profile modules,
138 While this is possible with standard cProfile or profile modules,
139 IPython wraps this functionality with magic commands (see '%prun'
139 IPython wraps this functionality with magic commands (see '%prun'
140 and '%run -p') convenient for rapid interactive work.
140 and '%run -p') convenient for rapid interactive work.
141 * Doctest support. The special %doctest_mode command toggles a mode
141 * Doctest support. The special %doctest_mode command toggles a mode
142 that allows you to paste existing doctests (with leading '>>>'
142 that allows you to paste existing doctests (with leading '>>>'
143 prompts and whitespace) and uses doctest-compatible prompts and
143 prompts and whitespace) and uses doctest-compatible prompts and
144 output, so you can use IPython sessions as doctest code.
144 output, so you can use IPython sessions as doctest code.
145
145
146
146
147 Portability and Python requirements
147 Portability and Python requirements
148 -----------------------------------
148 -----------------------------------
149
149
150 Python requirements: IPython requires with Python version 2.3 or newer.
150 Python requirements: IPython requires with Python version 2.3 or newer.
151 If you are still using Python 2.2 and can not upgrade, the last version
151 If you are still using Python 2.2 and can not upgrade, the last version
152 of IPython which worked with Python 2.2 was 0.6.15, so you will have to
152 of IPython which worked with Python 2.2 was 0.6.15, so you will have to
153 use that.
153 use that.
154
154
155 IPython is developed under Linux, but it should work in any reasonable
155 IPython is developed under Linux, but it should work in any reasonable
156 Unix-type system (tested OK under Solaris and the BSD family, for which
156 Unix-type system (tested OK under Solaris and the BSD family, for which
157 a port exists thanks to Dryice Liu).
157 a port exists thanks to Dryice Liu).
158
158
159 Mac OS X: it works, apparently without any problems (thanks to Jim Boyle
159 Mac OS X: it works, apparently without any problems (thanks to Jim Boyle
160 at Lawrence Livermore for the information). Thanks to Andrea Riciputi,
160 at Lawrence Livermore for the information). Thanks to Andrea Riciputi,
161 Fink support is available.
161 Fink support is available.
162
162
163 CygWin: it works mostly OK, though some users have reported problems
163 CygWin: it works mostly OK, though some users have reported problems
164 with prompt coloring. No satisfactory solution to this has been found so
164 with prompt coloring. No satisfactory solution to this has been found so
165 far, you may want to disable colors permanently in the ipythonrc
165 far, you may want to disable colors permanently in the ipythonrc
166 configuration file if you experience problems. If you have proper color
166 configuration file if you experience problems. If you have proper color
167 support under cygwin, please post to the IPython mailing list so this
167 support under cygwin, please post to the IPython mailing list so this
168 issue can be resolved for all users.
168 issue can be resolved for all users.
169
169
170 Windows: it works well under Windows XP/2k, and I suspect NT should
170 Windows: it works well under Windows XP/2k, and I suspect NT should
171 behave similarly. Section 2.3 <node2.html#sub:Under-Windows> describes
171 behave similarly. Section 2.3 <node2.html#sub:Under-Windows> describes
172 installation details for Windows, including some additional tools needed
172 installation details for Windows, including some additional tools needed
173 on this platform.
173 on this platform.
174
174
175 Windows 9x support is present, and has been reported to work fine (at
175 Windows 9x support is present, and has been reported to work fine (at
176 least on WinME).
176 least on WinME).
177
177
178 Note, that I have very little access to and experience with Windows
178 Note, that I have very little access to and experience with Windows
179 development. However, an excellent group of Win32 users (led by Ville
179 development. However, an excellent group of Win32 users (led by Ville
180 Vainio), consistently contribute bugfixes and platform-specific
180 Vainio), consistently contribute bugfixes and platform-specific
181 enhancements, so they more than make up for my deficiencies on that
181 enhancements, so they more than make up for my deficiencies on that
182 front. In fact, Win32 users report using IPython as a system shell (see
182 front. In fact, Win32 users report using IPython as a system shell (see
183 Sec. 12 <node12.html#sec:IPython-as-shell> for details), as it offers a
183 Sec. 12 <node12.html#sec:IPython-as-shell> for details), as it offers a
184 level of control and features which the default cmd.exe doesn't provide.
184 level of control and features which the default cmd.exe doesn't provide.
185
185
186
186
187 Location
187 Location
188 ========
188 ========
189
189
190 IPython is generously hosted at http://ipython.scipy.org by the
190 IPython is generously hosted at http://ipython.scipy.org by the
191 Enthought, Inc and the SciPy project. This site offers downloads,
191 Enthought, Inc and the SciPy project. This site offers downloads,
192 subversion access, mailing lists and a bug tracking system. I am very
192 subversion access, mailing lists and a bug tracking system. I am very
193 grateful to Enthought (http://www.enthought.com) and all of the SciPy
193 grateful to Enthought (http://www.enthought.com) and all of the SciPy
194 team for their contribution.
194 team for their contribution.
195
195
196 Installation
196 Installation
197 ============
197 ============
198
198
199 Instant instructions
199 Instant instructions
200 --------------------
200 --------------------
201
201
202 If you are of the impatient kind, under Linux/Unix simply untar/unzip
202 If you are of the impatient kind, under Linux/Unix simply untar/unzip
203 the download, then install with 'python setup.py install'. Under
203 the download, then install with 'python setup.py install'. Under
204 Windows, double-click on the provided .exe binary installer.
204 Windows, double-click on the provided .exe binary installer.
205
205
206 Then, take a look at Sections 3 <node3.html#sec:good_config> for
206 Then, take a look at Sections 3 <node3.html#sec:good_config> for
207 configuring things optimally and 4 <node4.html#sec:quick_tips> for quick
207 configuring things optimally and 4 <node4.html#sec:quick_tips> for quick
208 tips on efficient use of IPython. You can later refer to the rest of the
208 tips on efficient use of IPython. You can later refer to the rest of the
209 manual for all the gory details.
209 manual for all the gory details.
210
210
211 See the notes in sec. 2.4 <#sec:upgrade> for upgrading IPython versions.
211 See the notes in sec. 2.4 <#sec:upgrade> for upgrading IPython versions.
212
212
213
213
214 Detailed Unix instructions (Linux, Mac OS X, etc.)
214 Detailed Unix instructions (Linux, Mac OS X, etc.)
215
215
216 For RPM based systems, simply install the supplied package in the usual
216 For RPM based systems, simply install the supplied package in the usual
217 manner. If you download the tar archive, the process is:
217 manner. If you download the tar archive, the process is:
218
218
219 1. Unzip/untar the ipython-XXX.tar.gz file wherever you want (XXX is
219 1. Unzip/untar the ipython-XXX.tar.gz file wherever you want (XXX is
220 the version number). It will make a directory called ipython-XXX.
220 the version number). It will make a directory called ipython-XXX.
221 Change into that directory where you will find the files README
221 Change into that directory where you will find the files README
222 and setup.py. Once you've completed the installation, you can
222 and setup.py. Once you've completed the installation, you can
223 safely remove this directory.
223 safely remove this directory.
224 2. If you are installing over a previous installation of version
224 2. If you are installing over a previous installation of version
225 0.2.0 or earlier, first remove your $HOME/.ipython directory,
225 0.2.0 or earlier, first remove your $HOME/.ipython directory,
226 since the configuration file format has changed somewhat (the '='
226 since the configuration file format has changed somewhat (the '='
227 were removed from all option specifications). Or you can call
227 were removed from all option specifications). Or you can call
228 ipython with the -upgrade option and it will do this automatically
228 ipython with the -upgrade option and it will do this automatically
229 for you.
229 for you.
230 3. IPython uses distutils, so you can install it by simply typing at
230 3. IPython uses distutils, so you can install it by simply typing at
231 the system prompt (don't type the $)
231 the system prompt (don't type the $)::
232
232 $ python setup.py install
233 $ python setup.py install
234
233 Note that this assumes you have root access to your machine. If
235 Note that this assumes you have root access to your machine. If
234 you don't have root access or don't want IPython to go in the
236 you don't have root access or don't want IPython to go in the
235 default python directories, you'll need to use the |--home| option
237 default python directories, you'll need to use the ``--home`` option
236 (or |--prefix|). For example:
238 (or ``--prefix``). For example::
237 |$ python setup.py install --home $HOME/local|
239
240 $ python setup.py install --home $HOME/local
241
238 will install IPython into $HOME/local and its subdirectories
242 will install IPython into $HOME/local and its subdirectories
239 (creating them if necessary).
243 (creating them if necessary).
240 You can type
244 You can type::
241 |$ python setup.py --help|
245
246 $ python setup.py --help
247
242 for more details.
248 for more details.
243 Note that if you change the default location for |--home| at
249
250 Note that if you change the default location for ``--home`` at
244 installation, IPython may end up installed at a location which is
251 installation, IPython may end up installed at a location which is
245 not part of your $PYTHONPATH environment variable. In this case,
252 not part of your $PYTHONPATH environment variable. In this case,
246 you'll need to configure this variable to include the actual
253 you'll need to configure this variable to include the actual
247 directory where the IPython/ directory ended (typically the value
254 directory where the IPython/ directory ended (typically the value
248 you give to |--home| plus /lib/python).
255 you give to ``--home`` plus /lib/python).
249
256
250
257
251 Mac OSX information
258 Mac OSX information
252 -------------------
259 -------------------
253
260
254 Under OSX, there is a choice you need to make. Apple ships its own build
261 Under OSX, there is a choice you need to make. Apple ships its own build
255 of Python, which lives in the core OSX filesystem hierarchy. You can
262 of Python, which lives in the core OSX filesystem hierarchy. You can
256 also manually install a separate Python, either purely by hand
263 also manually install a separate Python, either purely by hand
257 (typically in /usr/local) or by using Fink, which puts everything under
264 (typically in /usr/local) or by using Fink, which puts everything under
258 /sw. Which route to follow is a matter of personal preference, as I've
265 /sw. Which route to follow is a matter of personal preference, as I've
259 seen users who favor each of the approaches. Here I will simply list the
266 seen users who favor each of the approaches. Here I will simply list the
260 known installation issues under OSX, along with their solutions.
267 known installation issues under OSX, along with their solutions.
261
268
262 This page: http://geosci.uchicago.edu/~tobis/pylab.html contains
269 This page: http://geosci.uchicago.edu/~tobis/pylab.html contains
263 information on this topic, with additional details on how to make
270 information on this topic, with additional details on how to make
264 IPython and matplotlib play nicely under OSX.
271 IPython and matplotlib play nicely under OSX.
265
272
266
273
267 GUI problems
274 GUI problems
268 ------------
275 ------------
269
276
270 The following instructions apply to an install of IPython under OSX from
277 The following instructions apply to an install of IPython under OSX from
271 unpacking the .tar.gz distribution and installing it for the default
278 unpacking the .tar.gz distribution and installing it for the default
272 Python interpreter shipped by Apple. If you are using a fink install,
279 Python interpreter shipped by Apple. If you are using a fink install,
273 fink will take care of these details for you, by installing IPython
280 fink will take care of these details for you, by installing IPython
274 against fink's Python.
281 against fink's Python.
275
282
276 IPython offers various forms of support for interacting with graphical
283 IPython offers various forms of support for interacting with graphical
277 applications from the command line, from simple Tk apps (which are in
284 applications from the command line, from simple Tk apps (which are in
278 principle always supported by Python) to interactive control of WX, Qt
285 principle always supported by Python) to interactive control of WX, Qt
279 and GTK apps. Under OSX, however, this requires that ipython is
286 and GTK apps. Under OSX, however, this requires that ipython is
280 installed by calling the special pythonw script at installation time,
287 installed by calling the special pythonw script at installation time,
281 which takes care of coordinating things with Apple's graphical environment.
288 which takes care of coordinating things with Apple's graphical environment.
282
289
283 So when installing under OSX, it is best to use the following command:
290 So when installing under OSX, it is best to use the following command::
284 | $ sudo pythonw setup.py install --install-scripts=/usr/local/bin|
291
292 $ sudo pythonw setup.py install --install-scripts=/usr/local/bin
293
285 or
294 or
286 | $ sudo pythonw setup.py install --install-scripts=/usr/bin|
295
296 $ sudo pythonw setup.py install --install-scripts=/usr/bin
297
287 depending on where you like to keep hand-installed executables.
298 depending on where you like to keep hand-installed executables.
288
299
289 The resulting script will have an appropriate shebang line (the first
300 The resulting script will have an appropriate shebang line (the first
290 line in the script whic begins with #!...) such that the ipython
301 line in the script whic begins with #!...) such that the ipython
291 interpreter can interact with the OS X GUI. If the installed version
302 interpreter can interact with the OS X GUI. If the installed version
292 does not work and has a shebang line that points to, for example, just
303 does not work and has a shebang line that points to, for example, just
293 /usr/bin/python, then you might have a stale, cached version in your
304 /usr/bin/python, then you might have a stale, cached version in your
294 build/scripts-<python-version> directory. Delete that directory and
305 build/scripts-<python-version> directory. Delete that directory and
295 rerun the setup.py.
306 rerun the setup.py.
296
307
297 It is also a good idea to use the special flag |--install-scripts| as
308 It is also a good idea to use the special flag ``--install-scripts`` as
298 indicated above, to ensure that the ipython scripts end up in a location
309 indicated above, to ensure that the ipython scripts end up in a location
299 which is part of your $PATH. Otherwise Apple's Python will put the
310 which is part of your $PATH. Otherwise Apple's Python will put the
300 scripts in an internal directory not available by default at the command
311 scripts in an internal directory not available by default at the command
301 line (if you use /usr/local/bin, you need to make sure this is in your
312 line (if you use /usr/local/bin, you need to make sure this is in your
302 $PATH, which may not be true by default).
313 $PATH, which may not be true by default).
303
314
304
315
305 Readline problems
316 Readline problems
306 -----------------
317 -----------------
307
318
308 By default, the Python version shipped by Apple does not include the
319 By default, the Python version shipped by Apple does not include the
309 readline library, so central to IPython's behavior. If you install
320 readline library, so central to IPython's behavior. If you install
310 IPython against Apple's Python, you will not have arrow keys, tab
321 IPython against Apple's Python, you will not have arrow keys, tab
311 completion, etc. For Mac OSX 10.3 (Panther), you can find a prebuilt
322 completion, etc. For Mac OSX 10.3 (Panther), you can find a prebuilt
312 readline library here:
323 readline library here:
313 http://pythonmac.org/packages/readline-5.0-py2.3-macosx10.3.zip
324 http://pythonmac.org/packages/readline-5.0-py2.3-macosx10.3.zip
314
325
315 If you are using OSX 10.4 (Tiger), after installing this package you
326 If you are using OSX 10.4 (Tiger), after installing this package you
316 need to either:
327 need to either:
317
328
318 1. move readline.so from /Library/Python/2.3 to
329 1. move readline.so from /Library/Python/2.3 to
319 /Library/Python/2.3/site-packages, or
330 /Library/Python/2.3/site-packages, or
320 2. install http://pythonmac.org/packages/TigerPython23Compat.pkg.zip
331 2. install http://pythonmac.org/packages/TigerPython23Compat.pkg.zip
321
332
322 Users installing against Fink's Python or a properly hand-built one
333 Users installing against Fink's Python or a properly hand-built one
323 should not have this problem.
334 should not have this problem.
324
335
325
336
326 DarwinPorts
337 DarwinPorts
327 -----------
338 -----------
328
339
329 I report here a message from an OSX user, who suggests an alternative
340 I report here a message from an OSX user, who suggests an alternative
330 means of using IPython under this operating system with good results.
341 means of using IPython under this operating system with good results.
331 Please let me know of any updates that may be useful for this section.
342 Please let me know of any updates that may be useful for this section.
332 His message is reproduced verbatim below:
343 His message is reproduced verbatim below:
333
344
334 From: Markus Banfi <markus.banfi-AT-mospheira.net>
345 From: Markus Banfi <markus.banfi-AT-mospheira.net>
335
346
336 As a MacOS X (10.4.2) user I prefer to install software using
347 As a MacOS X (10.4.2) user I prefer to install software using
337 DawinPorts instead of Fink. I had no problems installing ipython
348 DawinPorts instead of Fink. I had no problems installing ipython
338 with DarwinPorts. It's just:
349 with DarwinPorts. It's just:
339
350
340 sudo port install py-ipython
351 sudo port install py-ipython
341
352
342 It automatically resolved all dependencies (python24, readline,
353 It automatically resolved all dependencies (python24, readline,
343 py-readline). So far I did not encounter any problems with the
354 py-readline). So far I did not encounter any problems with the
344 DarwinPorts port of ipython.
355 DarwinPorts port of ipython.
345
356
346
357
347
358
348 Windows instructions
359 Windows instructions
349 --------------------
360 --------------------
350
361
351 Some of IPython's very useful features are:
362 Some of IPython's very useful features are:
352
363
353 * Integrated readline support (Tab-based file, object and attribute
364 * Integrated readline support (Tab-based file, object and attribute
354 completion, input history across sessions, editable command line,
365 completion, input history across sessions, editable command line,
355 etc.)
366 etc.)
356 * Coloring of prompts, code and tracebacks.
367 * Coloring of prompts, code and tracebacks.
357
368
358 These, by default, are only available under Unix-like operating systems.
369 These, by default, are only available under Unix-like operating systems.
359 However, thanks to Gary Bishop's work, Windows XP/2k users can also
370 However, thanks to Gary Bishop's work, Windows XP/2k users can also
360 benefit from them. His readline library originally implemented both GNU
371 benefit from them. His readline library originally implemented both GNU
361 readline functionality and color support, so that IPython under Windows
372 readline functionality and color support, so that IPython under Windows
362 XP/2k can be as friendly and powerful as under Unix-like environments.
373 XP/2k can be as friendly and powerful as under Unix-like environments.
363
374
364 This library, now named PyReadline, has been absorbed by the IPython
375 This library, now named PyReadline, has been absorbed by the IPython
365 team (Jörgen Stenarson, in particular), and it continues to be developed
376 team (Jörgen Stenarson, in particular), and it continues to be developed
366 with new features, as well as being distributed directly from the
377 with new features, as well as being distributed directly from the
367 IPython site.
378 IPython site.
368
379
369 The PyReadline extension requires CTypes and the windows IPython
380 The PyReadline extension requires CTypes and the windows IPython
370 installer needs PyWin32, so in all you need:
381 installer needs PyWin32, so in all you need:
371
382
372 1. PyWin32 from http://sourceforge.net/projects/pywin32.
383 1. PyWin32 from http://sourceforge.net/projects/pywin32.
373 2. PyReadline for Windows from
384 2. PyReadline for Windows from
374 http://ipython.scipy.org/moin/PyReadline/Intro. That page contains
385 http://ipython.scipy.org/moin/PyReadline/Intro. That page contains
375 further details on using and configuring the system to your liking.
386 further details on using and configuring the system to your liking.
376 3. Finally, only if you are using Python 2.3 or 2.4, you need CTypes
387 3. Finally, only if you are using Python 2.3 or 2.4, you need CTypes
377 from http://starship.python.net/crew/theller/ctypes(you must use
388 from http://starship.python.net/crew/theller/ctypes(you must use
378 version 0.9.1 or newer). This package is included in Python 2.5,
389 version 0.9.1 or newer). This package is included in Python 2.5,
379 so you don't need to manually get it if your Python version is 2.5
390 so you don't need to manually get it if your Python version is 2.5
380 or newer.
391 or newer.
381
392
382 Warning about a broken readline-like library: several users have
393 Warning about a broken readline-like library: several users have
383 reported problems stemming from using the pseudo-readline library at
394 reported problems stemming from using the pseudo-readline library at
384 http://newcenturycomputers.net/projects/readline.html. This is a broken
395 http://newcenturycomputers.net/projects/readline.html. This is a broken
385 library which, while called readline, only implements an incomplete
396 library which, while called readline, only implements an incomplete
386 subset of the readline API. Since it is still called readline, it fools
397 subset of the readline API. Since it is still called readline, it fools
387 IPython's detection mechanisms and causes unpredictable crashes later.
398 IPython's detection mechanisms and causes unpredictable crashes later.
388 If you wish to use IPython under Windows, you must NOT use this library,
399 If you wish to use IPython under Windows, you must NOT use this library,
389 which for all purposes is (at least as of version 1.6) terminally broken.
400 which for all purposes is (at least as of version 1.6) terminally broken.
390
401
391
402
392 Installation procedure
403 Installation procedure
393 ----------------------
404 ----------------------
394
405
395 Once you have the above installed, from the IPython download directory
406 Once you have the above installed, from the IPython download directory
396 grab the ipython-XXX.win32.exe file, where XXX represents the version
407 grab the ipython-XXX.win32.exe file, where XXX represents the version
397 number. This is a regular windows executable installer, which you can
408 number. This is a regular windows executable installer, which you can
398 simply double-click to install. It will add an entry for IPython to your
409 simply double-click to install. It will add an entry for IPython to your
399 Start Menu, as well as registering IPython in the Windows list of
410 Start Menu, as well as registering IPython in the Windows list of
400 applications, so you can later uninstall it from the Control Panel.
411 applications, so you can later uninstall it from the Control Panel.
401
412
402 IPython tries to install the configuration information in a directory
413 IPython tries to install the configuration information in a directory
403 named .ipython (_ipython under Windows) located in your 'home'
414 named .ipython (_ipython under Windows) located in your 'home'
404 directory. IPython sets this directory by looking for a HOME environment
415 directory. IPython sets this directory by looking for a HOME environment
405 variable; if such a variable does not exist, it uses HOMEDRIVE\HOMEPATH
416 variable; if such a variable does not exist, it uses HOMEDRIVE\HOMEPATH
406 (these are always defined by Windows). This typically gives something
417 (these are always defined by Windows). This typically gives something
407 like C:\Documents and Settings\YourUserName, but your local details may
418 like C:\Documents and Settings\YourUserName, but your local details may
408 vary. In this directory you will find all the files that configure
419 vary. In this directory you will find all the files that configure
409 IPython's defaults, and you can put there your profiles and extensions.
420 IPython's defaults, and you can put there your profiles and extensions.
410 This directory is automatically added by IPython to sys.path, so
421 This directory is automatically added by IPython to sys.path, so
411 anything you place there can be found by import statements.
422 anything you place there can be found by import statements.
412
423
413
424
414 Upgrading
425 Upgrading
415 ---------
426 ---------
416
427
417 For an IPython upgrade, you should first uninstall the previous version.
428 For an IPython upgrade, you should first uninstall the previous version.
418 This will ensure that all files and directories (such as the
429 This will ensure that all files and directories (such as the
419 documentation) which carry embedded version strings in their names are
430 documentation) which carry embedded version strings in their names are
420 properly removed.
431 properly removed.
421
432
422
433
423 Manual installation under Win32
434 Manual installation under Win32
424 -------------------------------
435 -------------------------------
425
436
426 In case the automatic installer does not work for some reason, you can
437 In case the automatic installer does not work for some reason, you can
427 download the ipython-XXX.tar.gz file, which contains the full IPython
438 download the ipython-XXX.tar.gz file, which contains the full IPython
428 source distribution (the popular WinZip can read .tar.gz files). After
439 source distribution (the popular WinZip can read .tar.gz files). After
429 uncompressing the archive, you can install it at a command terminal just
440 uncompressing the archive, you can install it at a command terminal just
430 like any other Python module, by using 'python setup.py install'.
441 like any other Python module, by using 'python setup.py install'.
431
442
432 After the installation, run the supplied win32_manual_post_install.py
443 After the installation, run the supplied win32_manual_post_install.py
433 script, which creates the necessary Start Menu shortcuts for you.
444 script, which creates the necessary Start Menu shortcuts for you.
434
445
435
446
436
447
437 Upgrading from a previous version
448 Upgrading from a previous version
438 ---------------------------------
449 ---------------------------------
439
450
440 If you are upgrading from a previous version of IPython, after doing the
451 If you are upgrading from a previous version of IPython, after doing the
441 routine installation described above, you should call IPython with the
452 routine installation described above, you should call IPython with the
442 -upgrade option the first time you run your new copy. This will
453 -upgrade option the first time you run your new copy. This will
443 automatically update your configuration directory while preserving
454 automatically update your configuration directory while preserving
444 copies of your old files. You can then later merge back any personal
455 copies of your old files. You can then later merge back any personal
445 customizations you may have made into the new files. It is a good idea
456 customizations you may have made into the new files. It is a good idea
446 to do this as there may be new options available in the new
457 to do this as there may be new options available in the new
447 configuration files which you will not have.
458 configuration files which you will not have.
448
459
449 Under Windows, if you don't know how to call python scripts with
460 Under Windows, if you don't know how to call python scripts with
450 arguments from a command line, simply delete the old config directory
461 arguments from a command line, simply delete the old config directory
451 and IPython will make a new one. Win2k and WinXP users will find it in
462 and IPython will make a new one. Win2k and WinXP users will find it in
452 C:\Documents and Settings\YourUserName\_ipython, and Win 9x users under
463 C:\Documents and Settings\YourUserName\_ipython, and Win 9x users under
453 C:\Program Files\IPython\_ipython.
464 C:\Program Files\IPython\_ipython.
454
465
455 Initial configuration of your environment
466 Initial configuration of your environment
456 =========================================
467 =========================================
457
468
458 This section will help you set various things in your environment for
469 This section will help you set various things in your environment for
459 your IPython sessions to be as efficient as possible. All of IPython's
470 your IPython sessions to be as efficient as possible. All of IPython's
460 configuration information, along with several example files, is stored
471 configuration information, along with several example files, is stored
461 in a directory named by default $HOME/.ipython. You can change this by
472 in a directory named by default $HOME/.ipython. You can change this by
462 defining the environment variable IPYTHONDIR, or at runtime with the
473 defining the environment variable IPYTHONDIR, or at runtime with the
463 command line option -ipythondir.
474 command line option -ipythondir.
464
475
465 If all goes well, the first time you run IPython it should automatically
476 If all goes well, the first time you run IPython it should automatically
466 create a user copy of the config directory for you, based on its builtin
477 create a user copy of the config directory for you, based on its builtin
467 defaults. You can look at the files it creates to learn more about
478 defaults. You can look at the files it creates to learn more about
468 configuring the system. The main file you will modify to configure
479 configuring the system. The main file you will modify to configure
469 IPython's behavior is called ipythonrc (with a .ini extension under
480 IPython's behavior is called ipythonrc (with a .ini extension under
470 Windows), included for reference in Sec. 7.1
481 Windows), included for reference in Sec. 7.1
471 <node7.html#sec:ipytonrc-sample>. This file is very commented and has
482 <node7.html#sec:ipytonrc-sample>. This file is very commented and has
472 many variables you can change to suit your taste, you can find more
483 many variables you can change to suit your taste, you can find more
473 details in Sec. 7 <node7.html#sec:customization>. Here we discuss the
484 details in Sec. 7 <node7.html#sec:customization>. Here we discuss the
474 basic things you will want to make sure things are working properly from
485 basic things you will want to make sure things are working properly from
475 the beginning.
486 the beginning.
476
487
477
488
478
489
479 Access to the Python help system
490 Access to the Python help system
480 --------------------------------
491 --------------------------------
481
492
482 This is true for Python in general (not just for IPython): you should
493 This is true for Python in general (not just for IPython): you should
483 have an environment variable called PYTHONDOCS pointing to the directory
494 have an environment variable called PYTHONDOCS pointing to the directory
484 where your HTML Python documentation lives. In my system it's
495 where your HTML Python documentation lives. In my system it's
485 /usr/share/doc/python-docs-2.3.4/html, check your local details or ask
496 /usr/share/doc/python-docs-2.3.4/html, check your local details or ask
486 your systems administrator.
497 your systems administrator.
487
498
488 This is the directory which holds the HTML version of the Python
499 This is the directory which holds the HTML version of the Python
489 manuals. Unfortunately it seems that different Linux distributions
500 manuals. Unfortunately it seems that different Linux distributions
490 package these files differently, so you may have to look around a bit.
501 package these files differently, so you may have to look around a bit.
491 Below I show the contents of this directory on my system for reference::
502 Below I show the contents of this directory on my system for reference::
492
503
493 [html]> ls
504 [html]> ls
494 about.dat acks.html dist/ ext/ index.html lib/ modindex.html
505 about.dat acks.html dist/ ext/ index.html lib/ modindex.html
495 stdabout.dat tut/ about.html api/ doc/ icons/ inst/ mac/ ref/ style.css
506 stdabout.dat tut/ about.html api/ doc/ icons/ inst/ mac/ ref/ style.css
496
507
497 You should really make sure this variable is correctly set so that
508 You should really make sure this variable is correctly set so that
498 Python's pydoc-based help system works. It is a powerful and convenient
509 Python's pydoc-based help system works. It is a powerful and convenient
499 system with full access to the Python manuals and all modules accessible
510 system with full access to the Python manuals and all modules accessible
500 to you.
511 to you.
501
512
502 Under Windows it seems that pydoc finds the documentation automatically,
513 Under Windows it seems that pydoc finds the documentation automatically,
503 so no extra setup appears necessary.
514 so no extra setup appears necessary.
504
515
505
516
506 Editor
517 Editor
507 ------
518 ------
508
519
509 The %edit command (and its alias %ed) will invoke the editor set in your
520 The %edit command (and its alias %ed) will invoke the editor set in your
510 environment as EDITOR. If this variable is not set, it will default to
521 environment as EDITOR. If this variable is not set, it will default to
511 vi under Linux/Unix and to notepad under Windows. You may want to set
522 vi under Linux/Unix and to notepad under Windows. You may want to set
512 this variable properly and to a lightweight editor which doesn't take
523 this variable properly and to a lightweight editor which doesn't take
513 too long to start (that is, something other than a new instance of
524 too long to start (that is, something other than a new instance of
514 Emacs). This way you can edit multi-line code quickly and with the power
525 Emacs). This way you can edit multi-line code quickly and with the power
515 of a real editor right inside IPython.
526 of a real editor right inside IPython.
516
527
517 If you are a dedicated Emacs user, you should set up the Emacs server so
528 If you are a dedicated Emacs user, you should set up the Emacs server so
518 that new requests are handled by the original process. This means that
529 that new requests are handled by the original process. This means that
519 almost no time is spent in handling the request (assuming an Emacs
530 almost no time is spent in handling the request (assuming an Emacs
520 process is already running). For this to work, you need to set your
531 process is already running). For this to work, you need to set your
521 EDITOR environment variable to 'emacsclient'. The code below, supplied
532 EDITOR environment variable to 'emacsclient'. The code below, supplied
522 by Francois Pinard, can then be used in your .emacs file to enable the
533 by Francois Pinard, can then be used in your .emacs file to enable the
523 server::
534 server::
524
535
525 (defvar server-buffer-clients)
536 (defvar server-buffer-clients)
526 (when (and (fboundp 'server-start) (string-equal (getenv "TERM") 'xterm))
537 (when (and (fboundp 'server-start) (string-equal (getenv "TERM") 'xterm))
527 (server-start)
538 (server-start)
528 (defun fp-kill-server-with-buffer-routine ()
539 (defun fp-kill-server-with-buffer-routine ()
529 (and server-buffer-clients (server-done)))
540 (and server-buffer-clients (server-done)))
530 (add-hook 'kill-buffer-hook 'fp-kill-server-with-buffer-routine))
541 (add-hook 'kill-buffer-hook 'fp-kill-server-with-buffer-routine))
531
542
532 You can also set the value of this editor via the commmand-line option
543 You can also set the value of this editor via the commmand-line option
533 '-editor' or in your ipythonrc file. This is useful if you wish to use
544 '-editor' or in your ipythonrc file. This is useful if you wish to use
534 specifically for IPython an editor different from your typical default
545 specifically for IPython an editor different from your typical default
535 (and for Windows users who tend to use fewer environment variables).
546 (and for Windows users who tend to use fewer environment variables).
536
547
537
548
538 Color
549 Color
539 -----
550 -----
540
551
541 The default IPython configuration has most bells and whistles turned on
552 The default IPython configuration has most bells and whistles turned on
542 (they're pretty safe). But there's one that may cause problems on some
553 (they're pretty safe). But there's one that may cause problems on some
543 systems: the use of color on screen for displaying information. This is
554 systems: the use of color on screen for displaying information. This is
544 very useful, since IPython can show prompts and exception tracebacks
555 very useful, since IPython can show prompts and exception tracebacks
545 with various colors, display syntax-highlighted source code, and in
556 with various colors, display syntax-highlighted source code, and in
546 general make it easier to visually parse information.
557 general make it easier to visually parse information.
547
558
548 The following terminals seem to handle the color sequences fine:
559 The following terminals seem to handle the color sequences fine:
549
560
550 * Linux main text console, KDE Konsole, Gnome Terminal, E-term,
561 * Linux main text console, KDE Konsole, Gnome Terminal, E-term,
551 rxvt, xterm.
562 rxvt, xterm.
552 * CDE terminal (tested under Solaris). This one boldfaces light colors.
563 * CDE terminal (tested under Solaris). This one boldfaces light colors.
553 * (X)Emacs buffers. See sec.3.4 <#sec:emacs> for more details on
564 * (X)Emacs buffers. See sec.3.4 <#sec:emacs> for more details on
554 using IPython with (X)Emacs.
565 using IPython with (X)Emacs.
555 * A Windows (XP/2k) command prompt with Gary Bishop's support
566 * A Windows (XP/2k) command prompt with Gary Bishop's support
556 extensions. Gary's extensions are discussed in Sec. 2.3
567 extensions. Gary's extensions are discussed in Sec. 2.3
557 <node2.html#sub:Under-Windows>.
568 <node2.html#sub:Under-Windows>.
558 * A Windows (XP/2k) CygWin shell. Although some users have reported
569 * A Windows (XP/2k) CygWin shell. Although some users have reported
559 problems; it is not clear whether there is an issue for everyone
570 problems; it is not clear whether there is an issue for everyone
560 or only under specific configurations. If you have full color
571 or only under specific configurations. If you have full color
561 support under cygwin, please post to the IPython mailing list so
572 support under cygwin, please post to the IPython mailing list so
562 this issue can be resolved for all users.
573 this issue can be resolved for all users.
563
574
564 These have shown problems:
575 These have shown problems:
565
576
566 * Windows command prompt in WinXP/2k logged into a Linux machine via
577 * Windows command prompt in WinXP/2k logged into a Linux machine via
567 telnet or ssh.
578 telnet or ssh.
568 * Windows native command prompt in WinXP/2k, without Gary Bishop's
579 * Windows native command prompt in WinXP/2k, without Gary Bishop's
569 extensions. Once Gary's readline library is installed, the normal
580 extensions. Once Gary's readline library is installed, the normal
570 WinXP/2k command prompt works perfectly.
581 WinXP/2k command prompt works perfectly.
571
582
572 Currently the following color schemes are available:
583 Currently the following color schemes are available:
573
584
574 * NoColor: uses no color escapes at all (all escapes are empty '' ''
585 * NoColor: uses no color escapes at all (all escapes are empty '' ''
575 strings). This 'scheme' is thus fully safe to use in any terminal.
586 strings). This 'scheme' is thus fully safe to use in any terminal.
576 * Linux: works well in Linux console type environments: dark
587 * Linux: works well in Linux console type environments: dark
577 background with light fonts. It uses bright colors for
588 background with light fonts. It uses bright colors for
578 information, so it is difficult to read if you have a light
589 information, so it is difficult to read if you have a light
579 colored background.
590 colored background.
580 * LightBG: the basic colors are similar to those in the Linux scheme
591 * LightBG: the basic colors are similar to those in the Linux scheme
581 but darker. It is easy to read in terminals with light backgrounds.
592 but darker. It is easy to read in terminals with light backgrounds.
582
593
583 IPython uses colors for two main groups of things: prompts and
594 IPython uses colors for two main groups of things: prompts and
584 tracebacks which are directly printed to the terminal, and the object
595 tracebacks which are directly printed to the terminal, and the object
585 introspection system which passes large sets of data through a pager.
596 introspection system which passes large sets of data through a pager.
586
597
587
598
588 Input/Output prompts and exception tracebacks
599 Input/Output prompts and exception tracebacks
589 ---------------------------------------------
600 ---------------------------------------------
590
601
591 You can test whether the colored prompts and tracebacks work on your
602 You can test whether the colored prompts and tracebacks work on your
592 system interactively by typing '%colors Linux' at the prompt (use
603 system interactively by typing '%colors Linux' at the prompt (use
593 '%colors LightBG' if your terminal has a light background). If the input
604 '%colors LightBG' if your terminal has a light background). If the input
594 prompt shows garbage like:
605 prompt shows garbage like:
595 [0;32mIn [[1;32m1[0;32m]: [0;00m
606 [0;32mIn [[1;32m1[0;32m]: [0;00m
596 instead of (in color) something like:
607 instead of (in color) something like:
597 In [1]:
608 In [1]:
598 this means that your terminal doesn't properly handle color escape
609 this means that your terminal doesn't properly handle color escape
599 sequences. You can go to a 'no color' mode by typing '%colors NoColor'.
610 sequences. You can go to a 'no color' mode by typing '%colors NoColor'.
600
611
601 You can try using a different terminal emulator program (Emacs users,
612 You can try using a different terminal emulator program (Emacs users,
602 see below). To permanently set your color preferences, edit the file
613 see below). To permanently set your color preferences, edit the file
603 $HOME/.ipython/ipythonrc and set the colors option to the desired value.
614 $HOME/.ipython/ipythonrc and set the colors option to the desired value.
604
615
605
616
606 Object details (types, docstrings, source code, etc.)
617 Object details (types, docstrings, source code, etc.)
607 -----------------------------------------------------
618 -----------------------------------------------------
608
619
609 IPython has a set of special functions for studying the objects you are
620 IPython has a set of special functions for studying the objects you are
610 working with, discussed in detail in Sec. 6.4
621 working with, discussed in detail in Sec. 6.4
611 <node6.html#sec:dyn-object-info>. But this system relies on passing
622 <node6.html#sec:dyn-object-info>. But this system relies on passing
612 information which is longer than your screen through a data pager, such
623 information which is longer than your screen through a data pager, such
613 as the common Unix less and more programs. In order to be able to see
624 as the common Unix less and more programs. In order to be able to see
614 this information in color, your pager needs to be properly configured. I
625 this information in color, your pager needs to be properly configured. I
615 strongly recommend using less instead of more, as it seems that more
626 strongly recommend using less instead of more, as it seems that more
616 simply can not understand colored text correctly.
627 simply can not understand colored text correctly.
617
628
618 In order to configure less as your default pager, do the following:
629 In order to configure less as your default pager, do the following:
619
630
620 1. Set the environment PAGER variable to less.
631 1. Set the environment PAGER variable to less.
621 2. Set the environment LESS variable to -r (plus any other options
632 2. Set the environment LESS variable to -r (plus any other options
622 you always want to pass to less by default). This tells less to
633 you always want to pass to less by default). This tells less to
623 properly interpret control sequences, which is how color
634 properly interpret control sequences, which is how color
624 information is given to your terminal.
635 information is given to your terminal.
625
636
626 For the csh or tcsh shells, add to your ~/.cshrc file the lines::
637 For the csh or tcsh shells, add to your ~/.cshrc file the lines::
627
638
628 setenv PAGER less
639 setenv PAGER less
629 setenv LESS -r
640 setenv LESS -r
630
641
631 There is similar syntax for other Unix shells, look at your system
642 There is similar syntax for other Unix shells, look at your system
632 documentation for details.
643 documentation for details.
633
644
634 If you are on a system which lacks proper data pagers (such as Windows),
645 If you are on a system which lacks proper data pagers (such as Windows),
635 IPython will use a very limited builtin pager.
646 IPython will use a very limited builtin pager.
636
647
637 (X)Emacs configuration
648 (X)Emacs configuration
638 ----------------------
649 ----------------------
639
650
640 Thanks to the work of Alexander Schmolck and Prabhu Ramachandran,
651 Thanks to the work of Alexander Schmolck and Prabhu Ramachandran,
641 currently (X)Emacs and IPython get along very well.
652 currently (X)Emacs and IPython get along very well.
642
653
643 Important note: You will need to use a recent enough version of
654 Important note: You will need to use a recent enough version of
644 python-mode.el, along with the file ipython.el. You can check that the
655 python-mode.el, along with the file ipython.el. You can check that the
645 version you have of python-mode.el is new enough by either looking at
656 version you have of python-mode.el is new enough by either looking at
646 the revision number in the file itself, or asking for it in (X)Emacs via
657 the revision number in the file itself, or asking for it in (X)Emacs via
647 M-x py-version. Versions 4.68 and newer contain the necessary fixes for
658 M-x py-version. Versions 4.68 and newer contain the necessary fixes for
648 proper IPython support.
659 proper IPython support.
649
660
650 The file ipython.el is included with the IPython distribution, in the
661 The file ipython.el is included with the IPython distribution, in the
651 documentation directory (where this manual resides in PDF and HTML
662 documentation directory (where this manual resides in PDF and HTML
652 formats).
663 formats).
653
664
654 Once you put these files in your Emacs path, all you need in your .emacs
665 Once you put these files in your Emacs path, all you need in your .emacs
655 file is::
666 file is::
656
667
657 (require 'ipython)
668 (require 'ipython)
658
669
659 This should give you full support for executing code snippets via
670 This should give you full support for executing code snippets via
660 IPython, opening IPython as your Python shell via C-c !, etc.
671 IPython, opening IPython as your Python shell via C-c !, etc.
661
672
662 If you happen to get garbage instead of colored prompts as described in
673 If you happen to get garbage instead of colored prompts as described in
663 the previous section, you may need to set also in your .emacs file::
674 the previous section, you may need to set also in your .emacs file::
664
675
665 (setq ansi-color-for-comint-mode t)
676 (setq ansi-color-for-comint-mode t)
666
677
667
678
668 Notes::
679 Notes:
669
680
670 * There is one caveat you should be aware of: you must start the
681 * There is one caveat you should be aware of: you must start the
671 IPython shell before attempting to execute any code regions via
682 IPython shell before attempting to execute any code regions via
672 C-c |. Simply type C-c ! to start IPython before passing any code
683 ``C-c |``. Simply type C-c ! to start IPython before passing any code
673 regions to the interpreter, and you shouldn't experience any
684 regions to the interpreter, and you shouldn't experience any
674 problems.
685 problems.
675 This is due to a bug in Python itself, which has been fixed for
686 This is due to a bug in Python itself, which has been fixed for
676 Python 2.3, but exists as of Python 2.2.2 (reported as SF bug [
687 Python 2.3, but exists as of Python 2.2.2 (reported as SF bug [
677 737947 ]).
688 737947 ]).
678 * The (X)Emacs support is maintained by Alexander Schmolck, so all
689 * The (X)Emacs support is maintained by Alexander Schmolck, so all
679 comments/requests should be directed to him through the IPython
690 comments/requests should be directed to him through the IPython
680 mailing lists.
691 mailing lists.
681 * This code is still somewhat experimental so it's a bit rough
692 * This code is still somewhat experimental so it's a bit rough
682 around the edges (although in practice, it works quite well).
693 around the edges (although in practice, it works quite well).
683 * Be aware that if you customize py-python-command previously, this
694 * Be aware that if you customize py-python-command previously, this
684 value will override what ipython.el does (because loading the
695 value will override what ipython.el does (because loading the
685 customization variables comes later).
696 customization variables comes later).
686
697
687 Quick tips
698 Quick tips
688 ==========
699 ==========
689
700
690 IPython can be used as an improved replacement for the Python prompt,
701 IPython can be used as an improved replacement for the Python prompt,
691 and for that you don't really need to read any more of this manual. But
702 and for that you don't really need to read any more of this manual. But
692 in this section we'll try to summarize a few tips on how to make the
703 in this section we'll try to summarize a few tips on how to make the
693 most effective use of it for everyday Python development, highlighting
704 most effective use of it for everyday Python development, highlighting
694 things you might miss in the rest of the manual (which is getting long).
705 things you might miss in the rest of the manual (which is getting long).
695 We'll give references to parts in the manual which provide more detail
706 We'll give references to parts in the manual which provide more detail
696 when appropriate.
707 when appropriate.
697
708
698 The following article by Jeremy Jones provides an introductory tutorial
709 The following article by Jeremy Jones provides an introductory tutorial
699 about IPython:
710 about IPython:
700 http://www.onlamp.com/pub/a/python/2005/01/27/ipython.html
711 http://www.onlamp.com/pub/a/python/2005/01/27/ipython.html
701
712
702 * The TAB key. TAB-completion, especially for attributes, is a
713 * The TAB key. TAB-completion, especially for attributes, is a
703 convenient way to explore the structure of any object you're
714 convenient way to explore the structure of any object you're
704 dealing with. Simply type object_name.<TAB> and a list of the
715 dealing with. Simply type object_name.<TAB> and a list of the
705 object's attributes will be printed (see sec. 6.5
716 object's attributes will be printed (see sec. 6.5
706 <node6.html#sec:readline> for more). Tab completion also works on
717 <node6.html#sec:readline> for more). Tab completion also works on
707 file and directory names, which combined with IPython's alias
718 file and directory names, which combined with IPython's alias
708 system allows you to do from within IPython many of the things you
719 system allows you to do from within IPython many of the things you
709 normally would need the system shell for.
720 normally would need the system shell for.
710 * Explore your objects. Typing object_name? will print all sorts of
721 * Explore your objects. Typing object_name? will print all sorts of
711 details about any object, including docstrings, function
722 details about any object, including docstrings, function
712 definition lines (for call arguments) and constructor details for
723 definition lines (for call arguments) and constructor details for
713 classes. The magic commands %pdoc, %pdef, %psource and %pfile will
724 classes. The magic commands %pdoc, %pdef, %psource and %pfile will
714 respectively print the docstring, function definition line, full
725 respectively print the docstring, function definition line, full
715 source code and the complete file for any object (when they can be
726 source code and the complete file for any object (when they can be
716 found). If automagic is on (it is by default), you don't need to
727 found). If automagic is on (it is by default), you don't need to
717 type the '%' explicitly. See sec. 6.4
728 type the '%' explicitly. See sec. 6.4
718 <node6.html#sec:dyn-object-info> for more.
729 <node6.html#sec:dyn-object-info> for more.
719 * The %run magic command allows you to run any python script and
730 * The %run magic command allows you to run any python script and
720 load all of its data directly into the interactive namespace.
731 load all of its data directly into the interactive namespace.
721 Since the file is re-read from disk each time, changes you make to
732 Since the file is re-read from disk each time, changes you make to
722 it are reflected immediately (in contrast to the behavior of
733 it are reflected immediately (in contrast to the behavior of
723 import). I rarely use import for code I am testing, relying on
734 import). I rarely use import for code I am testing, relying on
724 %run instead. See sec. 6.2 <node6.html#sec:magic> for more on this
735 %run instead. See sec. 6.2 <node6.html#sec:magic> for more on this
725 and other magic commands, or type the name of any magic command
736 and other magic commands, or type the name of any magic command
726 and ? to get details on it. See also sec. 6.9
737 and ? to get details on it. See also sec. 6.9
727 <node6.html#sec:dreload> for a recursive reload command.
738 <node6.html#sec:dreload> for a recursive reload command.
728 %run also has special flags for timing the execution of your
739 %run also has special flags for timing the execution of your
729 scripts (-t) and for executing them under the control of either
740 scripts (-t) and for executing them under the control of either
730 Python's pdb debugger (-d) or profiler (-p). With all of these,
741 Python's pdb debugger (-d) or profiler (-p). With all of these,
731 %run can be used as the main tool for efficient interactive
742 %run can be used as the main tool for efficient interactive
732 development of code which you write in your editor of choice.
743 development of code which you write in your editor of choice.
733 * Use the Python debugger, pdb^2 <footnode.html#foot360>. The %pdb
744 * Use the Python debugger, pdb^2 <footnode.html#foot360>. The %pdb
734 command allows you to toggle on and off the automatic invocation
745 command allows you to toggle on and off the automatic invocation
735 of an IPython-enhanced pdb debugger (with coloring, tab completion
746 of an IPython-enhanced pdb debugger (with coloring, tab completion
736 and more) at any uncaught exception. The advantage of this is that
747 and more) at any uncaught exception. The advantage of this is that
737 pdb starts inside the function where the exception occurred, with
748 pdb starts inside the function where the exception occurred, with
738 all data still available. You can print variables, see code,
749 all data still available. You can print variables, see code,
739 execute statements and even walk up and down the call stack to
750 execute statements and even walk up and down the call stack to
740 track down the true source of the problem (which often is many
751 track down the true source of the problem (which often is many
741 layers in the stack above where the exception gets triggered).
752 layers in the stack above where the exception gets triggered).
742 Running programs with %run and pdb active can be an efficient to
753 Running programs with %run and pdb active can be an efficient to
743 develop and debug code, in many cases eliminating the need for
754 develop and debug code, in many cases eliminating the need for
744 print statements or external debugging tools. I often simply put a
755 print statements or external debugging tools. I often simply put a
745 1/0 in a place where I want to take a look so that pdb gets
756 1/0 in a place where I want to take a look so that pdb gets
746 called, quickly view whatever variables I need to or test various
757 called, quickly view whatever variables I need to or test various
747 pieces of code and then remove the 1/0.
758 pieces of code and then remove the 1/0.
748 Note also that '%run -d' activates pdb and automatically sets
759 Note also that '%run -d' activates pdb and automatically sets
749 initial breakpoints for you to step through your code, watch
760 initial breakpoints for you to step through your code, watch
750 variables, etc. See Sec. 6.12 <node6.html#sec:cache_output> for
761 variables, etc. See Sec. 6.12 <node6.html#sec:cache_output> for
751 details.
762 details.
752 * Use the output cache. All output results are automatically stored
763 * Use the output cache. All output results are automatically stored
753 in a global dictionary named Out and variables named _1, _2, etc.
764 in a global dictionary named Out and variables named _1, _2, etc.
754 alias them. For example, the result of input line 4 is available
765 alias them. For example, the result of input line 4 is available
755 either as Out[4] or as _4. Additionally, three variables named _,
766 either as Out[4] or as _4. Additionally, three variables named _,
756 __ and ___ are always kept updated with the for the last three
767 __ and ___ are always kept updated with the for the last three
757 results. This allows you to recall any previous result and further
768 results. This allows you to recall any previous result and further
758 use it for new calculations. See Sec. 6.12
769 use it for new calculations. See Sec. 6.12
759 <node6.html#sec:cache_output> for more.
770 <node6.html#sec:cache_output> for more.
760 * Put a ';' at the end of a line to supress the printing of output.
771 * Put a ';' at the end of a line to supress the printing of output.
761 This is useful when doing calculations which generate long output
772 This is useful when doing calculations which generate long output
762 you are not interested in seeing. The _* variables and the Out[]
773 you are not interested in seeing. The _* variables and the Out[]
763 list do get updated with the contents of the output, even if it is
774 list do get updated with the contents of the output, even if it is
764 not printed. You can thus still access the generated results this
775 not printed. You can thus still access the generated results this
765 way for further processing.
776 way for further processing.
766 * A similar system exists for caching input. All input is stored in
777 * A similar system exists for caching input. All input is stored in
767 a global list called In , so you can re-execute lines 22 through
778 a global list called In , so you can re-execute lines 22 through
768 28 plus line 34 by typing 'exec In[22:29]+In[34]' (using Python
779 28 plus line 34 by typing 'exec In[22:29]+In[34]' (using Python
769 slicing notation). If you need to execute the same set of lines
780 slicing notation). If you need to execute the same set of lines
770 often, you can assign them to a macro with the %macro function.
781 often, you can assign them to a macro with the %macro function.
771 See sec. 6.11 <node6.html#sec:cache_input> for more.
782 See sec. 6.11 <node6.html#sec:cache_input> for more.
772 * Use your input history. The %hist command can show you all
783 * Use your input history. The %hist command can show you all
773 previous input, without line numbers if desired (option -n) so you
784 previous input, without line numbers if desired (option -n) so you
774 can directly copy and paste code either back in IPython or in a
785 can directly copy and paste code either back in IPython or in a
775 text editor. You can also save all your history by turning on
786 text editor. You can also save all your history by turning on
776 logging via %logstart; these logs can later be either reloaded as
787 logging via %logstart; these logs can later be either reloaded as
777 IPython sessions or used as code for your programs.
788 IPython sessions or used as code for your programs.
778 * Define your own system aliases. Even though IPython gives you
789 * Define your own system aliases. Even though IPython gives you
779 access to your system shell via the ! prefix, it is convenient to
790 access to your system shell via the ! prefix, it is convenient to
780 have aliases to the system commands you use most often. This
791 have aliases to the system commands you use most often. This
781 allows you to work seamlessly from inside IPython with the same
792 allows you to work seamlessly from inside IPython with the same
782 commands you are used to in your system shell.
793 commands you are used to in your system shell.
783 IPython comes with some pre-defined aliases and a complete system
794 IPython comes with some pre-defined aliases and a complete system
784 for changing directories, both via a stack (see %pushd, %popd and
795 for changing directories, both via a stack (see %pushd, %popd and
785 %dhist) and via direct %cd. The latter keeps a history of visited
796 %dhist) and via direct %cd. The latter keeps a history of visited
786 directories and allows you to go to any previously visited one.
797 directories and allows you to go to any previously visited one.
787 * Use Python to manipulate the results of system commands. The '!!'
798 * Use Python to manipulate the results of system commands. The '!!'
788 special syntax, and the %sc and %sx magic commands allow you to
799 special syntax, and the %sc and %sx magic commands allow you to
789 capture system output into Python variables.
800 capture system output into Python variables.
790 * Expand python variables when calling the shell (either via '!' and
801 * Expand python variables when calling the shell (either via '!' and
791 '!!' or via aliases) by prepending a $ in front of them. You can
802 '!!' or via aliases) by prepending a $ in front of them. You can
792 also expand complete python expressions. See sec. 6.7
803 also expand complete python expressions. See sec. 6.7
793 <node6.html#sub:System-shell-access> for more.
804 <node6.html#sub:System-shell-access> for more.
794 * Use profiles to maintain different configurations (modules to
805 * Use profiles to maintain different configurations (modules to
795 load, function definitions, option settings) for particular tasks.
806 load, function definitions, option settings) for particular tasks.
796 You can then have customized versions of IPython for specific
807 You can then have customized versions of IPython for specific
797 purposes. See sec. 7.3 <node7.html#sec:profiles> for more.
808 purposes. See sec. 7.3 <node7.html#sec:profiles> for more.
798 * Embed IPython in your programs. A few lines of code are enough to
809 * Embed IPython in your programs. A few lines of code are enough to
799 load a complete IPython inside your own programs, giving you the
810 load a complete IPython inside your own programs, giving you the
800 ability to work with your data interactively after automatic
811 ability to work with your data interactively after automatic
801 processing has been completed. See sec. 9 <node9.html#sec:embed>
812 processing has been completed. See sec. 9 <node9.html#sec:embed>
802 for more.
813 for more.
803 * Use the Python profiler. When dealing with performance issues, the
814 * Use the Python profiler. When dealing with performance issues, the
804 %run command with a -p option allows you to run complete programs
815 %run command with a -p option allows you to run complete programs
805 under the control of the Python profiler. The %prun command does a
816 under the control of the Python profiler. The %prun command does a
806 similar job for single Python expressions (like function calls).
817 similar job for single Python expressions (like function calls).
807 * Use the IPython.demo.Demo class to load any Python script as an
818 * Use the IPython.demo.Demo class to load any Python script as an
808 interactive demo. With a minimal amount of simple markup, you can
819 interactive demo. With a minimal amount of simple markup, you can
809 control the execution of the script, stopping as needed. See
820 control the execution of the script, stopping as needed. See
810 sec. 14 <node14.html#sec:interactive-demos> for more.
821 sec. 14 <node14.html#sec:interactive-demos> for more.
811 * Run your doctests from within IPython for development and
822 * Run your doctests from within IPython for development and
812 debugging. The special %doctest_mode command toggles a mode where
823 debugging. The special %doctest_mode command toggles a mode where
813 the prompt, output and exceptions display matches as closely as
824 the prompt, output and exceptions display matches as closely as
814 possible that of the default Python interpreter. In addition, this
825 possible that of the default Python interpreter. In addition, this
815 mode allows you to directly paste in code that contains leading
826 mode allows you to directly paste in code that contains leading
816 '>>>' prompts, even if they have extra leading whitespace (as is
827 '>>>' prompts, even if they have extra leading whitespace (as is
817 common in doctest files). This combined with the '%history -tn'
828 common in doctest files). This combined with the '%history -tn'
818 call to see your translated history (with these extra prompts
829 call to see your translated history (with these extra prompts
819 removed and no line numbers) allows for an easy doctest workflow,
830 removed and no line numbers) allows for an easy doctest workflow,
820 where you can go from doctest to interactive execution to pasting
831 where you can go from doctest to interactive execution to pasting
821 into valid Python code as needed.
832 into valid Python code as needed.
822
833
823
834
824 Source code handling tips
835 Source code handling tips
825 -------------------------
836 -------------------------
826
837
827 IPython is a line-oriented program, without full control of the
838 IPython is a line-oriented program, without full control of the
828 terminal. Therefore, it doesn't support true multiline editing. However,
839 terminal. Therefore, it doesn't support true multiline editing. However,
829 it has a number of useful tools to help you in dealing effectively with
840 it has a number of useful tools to help you in dealing effectively with
830 more complex editing.
841 more complex editing.
831
842
832 The %edit command gives a reasonable approximation of multiline editing,
843 The %edit command gives a reasonable approximation of multiline editing,
833 by invoking your favorite editor on the spot. IPython will execute the
844 by invoking your favorite editor on the spot. IPython will execute the
834 code you type in there as if it were typed interactively. Type %edit?
845 code you type in there as if it were typed interactively. Type %edit?
835 for the full details on the edit command.
846 for the full details on the edit command.
836
847
837 If you have typed various commands during a session, which you'd like to
848 If you have typed various commands during a session, which you'd like to
838 reuse, IPython provides you with a number of tools. Start by using %hist
849 reuse, IPython provides you with a number of tools. Start by using %hist
839 to see your input history, so you can see the line numbers of all input.
850 to see your input history, so you can see the line numbers of all input.
840 Let us say that you'd like to reuse lines 10 through 20, plus lines 24
851 Let us say that you'd like to reuse lines 10 through 20, plus lines 24
841 and 28. All the commands below can operate on these with the syntax::
852 and 28. All the commands below can operate on these with the syntax::
842
853
843 %command 10-20 24 28
854 %command 10-20 24 28
844
855
845 where the command given can be:
856 where the command given can be:
846
857
847 * %macro <macroname>: this stores the lines into a variable which,
858 * %macro <macroname>: this stores the lines into a variable which,
848 when called at the prompt, re-executes the input. Macros can be
859 when called at the prompt, re-executes the input. Macros can be
849 edited later using '%edit macroname', and they can be stored
860 edited later using '%edit macroname', and they can be stored
850 persistently across sessions with '%store macroname' (the storage
861 persistently across sessions with '%store macroname' (the storage
851 system is per-profile). The combination of quick macros,
862 system is per-profile). The combination of quick macros,
852 persistent storage and editing, allows you to easily refine
863 persistent storage and editing, allows you to easily refine
853 quick-and-dirty interactive input into permanent utilities, always
864 quick-and-dirty interactive input into permanent utilities, always
854 available both in IPython and as files for general reuse.
865 available both in IPython and as files for general reuse.
855 * %edit: this will open a text editor with those lines pre-loaded
866 * %edit: this will open a text editor with those lines pre-loaded
856 for further modification. It will then execute the resulting
867 for further modification. It will then execute the resulting
857 file's contents as if you had typed it at the prompt.
868 file's contents as if you had typed it at the prompt.
858 * %save <filename>: this saves the lines directly to a named file on
869 * %save <filename>: this saves the lines directly to a named file on
859 disk.
870 disk.
860
871
861 While %macro saves input lines into memory for interactive re-execution,
872 While %macro saves input lines into memory for interactive re-execution,
862 sometimes you'd like to save your input directly to a file. The %save
873 sometimes you'd like to save your input directly to a file. The %save
863 magic does this: its input sytnax is the same as %macro, but it saves
874 magic does this: its input sytnax is the same as %macro, but it saves
864 your input directly to a Python file. Note that the %logstart command
875 your input directly to a Python file. Note that the %logstart command
865 also saves input, but it logs all input to disk (though you can
876 also saves input, but it logs all input to disk (though you can
866 temporarily suspend it and reactivate it with %logoff/%logon); %save
877 temporarily suspend it and reactivate it with %logoff/%logon); %save
867 allows you to select which lines of input you need to save.
878 allows you to select which lines of input you need to save.
868
879
869
880
870 Lightweight 'version control'
881 Lightweight 'version control'
871 -----------------------------
882 -----------------------------
872
883
873 When you call %edit with no arguments, IPython opens an empty editor
884 When you call %edit with no arguments, IPython opens an empty editor
874 with a temporary file, and it returns the contents of your editing
885 with a temporary file, and it returns the contents of your editing
875 session as a string variable. Thanks to IPython's output caching
886 session as a string variable. Thanks to IPython's output caching
876 mechanism, this is automatically stored::
887 mechanism, this is automatically stored::
877
888
878 In [1]: %edit
889 In [1]: %edit
879
890
880 IPython will make a temporary file named: /tmp/ipython_edit_yR-HCN.py
891 IPython will make a temporary file named: /tmp/ipython_edit_yR-HCN.py
881
892
882 Editing... done. Executing edited code...
893 Editing... done. Executing edited code...
883
894
884 hello - this is a temporary file
895 hello - this is a temporary file
885
896
886 Out[1]: "print 'hello - this is a temporary file'\n"
897 Out[1]: "print 'hello - this is a temporary file'\n"
887
898
888 Now, if you call '%edit -p', IPython tries to open an editor with the
899 Now, if you call '%edit -p', IPython tries to open an editor with the
889 same data as the last time you used %edit. So if you haven't used %edit
900 same data as the last time you used %edit. So if you haven't used %edit
890 in the meantime, this same contents will reopen; however, it will be
901 in the meantime, this same contents will reopen; however, it will be
891 done in a new file. This means that if you make changes and you later
902 done in a new file. This means that if you make changes and you later
892 want to find an old version, you can always retrieve it by using its
903 want to find an old version, you can always retrieve it by using its
893 output number, via '%edit _NN', where NN is the number of the output
904 output number, via '%edit _NN', where NN is the number of the output
894 prompt.
905 prompt.
895
906
896 Continuing with the example above, this should illustrate this idea::
907 Continuing with the example above, this should illustrate this idea::
897
908
898 In [2]: edit -p
909 In [2]: edit -p
899
910
900 IPython will make a temporary file named: /tmp/ipython_edit_nA09Qk.py
911 IPython will make a temporary file named: /tmp/ipython_edit_nA09Qk.py
901
912
902 Editing... done. Executing edited code...
913 Editing... done. Executing edited code...
903
914
904 hello - now I made some changes
915 hello - now I made some changes
905
916
906 Out[2]: "print 'hello - now I made some changes'\n"
917 Out[2]: "print 'hello - now I made some changes'\n"
907
918
908 In [3]: edit _1
919 In [3]: edit _1
909
920
910 IPython will make a temporary file named: /tmp/ipython_edit_gy6-zD.py
921 IPython will make a temporary file named: /tmp/ipython_edit_gy6-zD.py
911
922
912 Editing... done. Executing edited code...
923 Editing... done. Executing edited code...
913
924
914 hello - this is a temporary file
925 hello - this is a temporary file
915
926
916 IPython version control at work :)
927 IPython version control at work :)
917
928
918 Out[3]: "print 'hello - this is a temporary file'\nprint 'IPython version control at work :)'\n"
929 Out[3]: "print 'hello - this is a temporary file'\nprint 'IPython version control at work :)'\n"
919
930
920
931
921 This section was written after a contribution by Alexander Belchenko on
932 This section was written after a contribution by Alexander Belchenko on
922 the IPython user list.
933 the IPython user list.
923
934
924
935
925 Effective logging
936 Effective logging
926 -----------------
937 -----------------
927
938
928 A very useful suggestion sent in by Robert Kern follows:
939 A very useful suggestion sent in by Robert Kern follows:
929
940
930 I recently happened on a nifty way to keep tidy per-project log files. I
941 I recently happened on a nifty way to keep tidy per-project log files. I
931 made a profile for my project (which is called "parkfield").
942 made a profile for my project (which is called "parkfield").
932
943
933 include ipythonrc
944 include ipythonrc
934
945
935 # cancel earlier logfile invocation:
946 # cancel earlier logfile invocation:
936
947
937 logfile ''
948 logfile ''
938
949
939 execute import time
950 execute import time
940
951
941 execute __cmd = '/Users/kern/research/logfiles/parkfield-%s.log rotate'
952 execute __cmd = '/Users/kern/research/logfiles/parkfield-%s.log rotate'
942
953
943 execute __IP.magic_logstart(__cmd % time.strftime('%Y-%m-%d'))
954 execute __IP.magic_logstart(__cmd % time.strftime('%Y-%m-%d'))
944
955
945 I also added a shell alias for convenience:
956 I also added a shell alias for convenience:
946
957
947 alias parkfield="ipython -pylab -profile parkfield"
958 alias parkfield="ipython -pylab -profile parkfield"
948
959
949 Now I have a nice little directory with everything I ever type in,
960 Now I have a nice little directory with everything I ever type in,
950 organized by project and date.
961 organized by project and date.
951
962
952 Contribute your own: If you have your own favorite tip on using IPython
963 Contribute your own: If you have your own favorite tip on using IPython
953 efficiently for a certain task (especially things which can't be done in
964 efficiently for a certain task (especially things which can't be done in
954 the normal Python interpreter), don't hesitate to send it!
965 the normal Python interpreter), don't hesitate to send it!
955
966
956 Command-line use
967 Command-line use
957 ================
968 ================
958
969
959 You start IPython with the command::
970 You start IPython with the command::
960
971
961 $ ipython [options] files
972 $ ipython [options] files
962
973
963 If invoked with no options, it executes all the files listed in sequence
974 If invoked with no options, it executes all the files listed in sequence
964 and drops you into the interpreter while still acknowledging any options
975 and drops you into the interpreter while still acknowledging any options
965 you may have set in your ipythonrc file. This behavior is different from
976 you may have set in your ipythonrc file. This behavior is different from
966 standard Python, which when called as python -i will only execute one
977 standard Python, which when called as python -i will only execute one
967 file and ignore your configuration setup.
978 file and ignore your configuration setup.
968
979
969 Please note that some of the configuration options are not available at
980 Please note that some of the configuration options are not available at
970 the command line, simply because they are not practical here. Look into
981 the command line, simply because they are not practical here. Look into
971 your ipythonrc configuration file for details on those. This file
982 your ipythonrc configuration file for details on those. This file
972 typically installed in the $HOME/.ipython directory. For Windows users,
983 typically installed in the $HOME/.ipython directory. For Windows users,
973 $HOME resolves to C:\\Documents and Settings\\YourUserName in most
984 $HOME resolves to C:\\Documents and Settings\\YourUserName in most
974 instances. In the rest of this text, we will refer to this directory as
985 instances. In the rest of this text, we will refer to this directory as
975 IPYTHONDIR.
986 IPYTHONDIR.
976
987
977
988
978 Special Threading Options
989 Special Threading Options
979
990
980 The following special options are ONLY valid at the beginning of the
991 The following special options are ONLY valid at the beginning of the
981 command line, and not later. This is because they control the initial-
992 command line, and not later. This is because they control the initial-
982 ization of ipython itself, before the normal option-handling mechanism
993 ization of ipython itself, before the normal option-handling mechanism
983 is active.
994 is active.
984
995
985 * [-gthread, -qthread, -q4thread, -wthread, -pylab:] Only one of
996 * [-gthread, -qthread, -q4thread, -wthread, -pylab:] Only one of
986 these can be given, and it can only be given as the first option
997 these can be given, and it can only be given as the first option
987 passed to IPython (it will have no effect in any other position).
998 passed to IPython (it will have no effect in any other position).
988 They provide threading support for the GTK, Qt (versions 3 and 4)
999 They provide threading support for the GTK, Qt (versions 3 and 4)
989 and WXPython toolkits, and for the matplotlib library.
1000 and WXPython toolkits, and for the matplotlib library.
990 * [ ] With any of the first four options, IPython starts running a
1001 * [ ] With any of the first four options, IPython starts running a
991 separate thread for the graphical toolkit's operation, so that you
1002 separate thread for the graphical toolkit's operation, so that you
992 can open and control graphical elements from within an IPython
1003 can open and control graphical elements from within an IPython
993 command line, without blocking. All four provide essentially the
1004 command line, without blocking. All four provide essentially the
994 same functionality, respectively for GTK, Qt3, Qt4 and WXWidgets
1005 same functionality, respectively for GTK, Qt3, Qt4 and WXWidgets
995 (via their Python interfaces).
1006 (via their Python interfaces).
996 * [ ] Note that with -wthread, you can additionally use the
1007 * [ ] Note that with -wthread, you can additionally use the
997 -wxversion option to request a specific version of wx to be used.
1008 -wxversion option to request a specific version of wx to be used.
998 This requires that you have the wxversion Python module installed,
1009 This requires that you have the wxversion Python module installed,
999 which is part of recent wxPython distributions.
1010 which is part of recent wxPython distributions.
1000 * [ ] If -pylab is given, IPython loads special support for the mat
1011 * [ ] If -pylab is given, IPython loads special support for the mat
1001 plotlib library (http://matplotlib.sourceforge.net), allowing
1012 plotlib library (http://matplotlib.sourceforge.net), allowing
1002 interactive usage of any of its backends as defined in the user's
1013 interactive usage of any of its backends as defined in the user's
1003 ~/.matplotlib/matplotlibrc file. It automatically activates GTK,
1014 ~/.matplotlib/matplotlibrc file. It automatically activates GTK,
1004 Qt or WX threading for IPyhton if the choice of matplotlib backend
1015 Qt or WX threading for IPyhton if the choice of matplotlib backend
1005 requires it. It also modifies the %run command to correctly
1016 requires it. It also modifies the %run command to correctly
1006 execute (without blocking) any matplotlib-based script which calls
1017 execute (without blocking) any matplotlib-based script which calls
1007 show() at the end.
1018 show() at the end.
1008 * [-tk] The -g/q/q4/wthread options, and -pylab (if matplotlib is
1019 * [-tk] The -g/q/q4/wthread options, and -pylab (if matplotlib is
1009 configured to use GTK, Qt3, Qt4 or WX), will normally block Tk
1020 configured to use GTK, Qt3, Qt4 or WX), will normally block Tk
1010 graphical interfaces. This means that when either GTK, Qt or WX
1021 graphical interfaces. This means that when either GTK, Qt or WX
1011 threading is active, any attempt to open a Tk GUI will result in a
1022 threading is active, any attempt to open a Tk GUI will result in a
1012 dead window, and possibly cause the Python interpreter to crash.
1023 dead window, and possibly cause the Python interpreter to crash.
1013 An extra option, -tk, is available to address this issue. It can
1024 An extra option, -tk, is available to address this issue. It can
1014 only be given as a second option after any of the above (-gthread,
1025 only be given as a second option after any of the above (-gthread,
1015 -wthread or -pylab).
1026 -wthread or -pylab).
1016 * [ ] If -tk is given, IPython will try to coordinate Tk threading
1027 * [ ] If -tk is given, IPython will try to coordinate Tk threading
1017 with GTK, Qt or WX. This is however potentially unreliable, and
1028 with GTK, Qt or WX. This is however potentially unreliable, and
1018 you will have to test on your platform and Python configuration to
1029 you will have to test on your platform and Python configuration to
1019 determine whether it works for you. Debian users have reported
1030 determine whether it works for you. Debian users have reported
1020 success, apparently due to the fact that Debian builds all of Tcl,
1031 success, apparently due to the fact that Debian builds all of Tcl,
1021 Tk, Tkinter and Python with pthreads support. Under other Linux
1032 Tk, Tkinter and Python with pthreads support. Under other Linux
1022 environments (such as Fedora Core 2/3), this option has caused
1033 environments (such as Fedora Core 2/3), this option has caused
1023 random crashes and lockups of the Python interpreter. Under other
1034 random crashes and lockups of the Python interpreter. Under other
1024 operating systems (Mac OSX and Windows), you'll need to try it to
1035 operating systems (Mac OSX and Windows), you'll need to try it to
1025 find out, since currently no user reports are available.
1036 find out, since currently no user reports are available.
1026 * [ ] There is unfortunately no way for IPython to determine at run
1037 * [ ] There is unfortunately no way for IPython to determine at run
1027 time whether -tk will work reliably or not, so you will need to do
1038 time whether -tk will work reliably or not, so you will need to do
1028 some experiments before relying on it for regular work.
1039 some experiments before relying on it for regular work.
1029
1040
1030
1041
1031
1042
1032 Regular Options
1043 Regular Options
1033 ---------------
1044 ---------------
1034
1045
1035 After the above threading options have been given, regular options can
1046 After the above threading options have been given, regular options can
1036 follow in any order. All options can be abbreviated to their shortest
1047 follow in any order. All options can be abbreviated to their shortest
1037 non-ambiguous form and are case-sensitive. One or two dashes can be
1048 non-ambiguous form and are case-sensitive. One or two dashes can be
1038 used. Some options have an alternate short form, indicated after a ``|``.
1049 used. Some options have an alternate short form, indicated after a ``|``.
1039
1050
1040 Most options can also be set from your ipythonrc configuration file. See
1051 Most options can also be set from your ipythonrc configuration file. See
1041 the provided example for more details on what the options do. Options
1052 the provided example for more details on what the options do. Options
1042 given at the command line override the values set in the ipythonrc file.
1053 given at the command line override the values set in the ipythonrc file.
1043
1054
1044 All options with a [no] prepended can be specified in negated form
1055 All options with a [no] prepended can be specified in negated form
1045 (-nooption instead of -option) to turn the feature off.
1056 (-nooption instead of -option) to turn the feature off.
1046
1057
1047 * [-help:] print a help message and exit.
1058 * [-help:] print a help message and exit.
1048 * [-pylab:] this can only be given as the first option passed to
1059 * [-pylab:] this can only be given as the first option passed to
1049 IPython (it will have no effect in any other position). It adds
1060 IPython (it will have no effect in any other position). It adds
1050 special support for the matplotlib library
1061 special support for the matplotlib library
1051 (http://matplotlib.sourceforge.net
1062 (http://matplotlib.sourceforge.net
1052 http://matplotlib.sourceforge.net), allowing interactive usage of
1063 http://matplotlib.sourceforge.net), allowing interactive usage of
1053 any of its backends as defined in the user's .matplotlibrc file.
1064 any of its backends as defined in the user's .matplotlibrc file.
1054 It automatically activates GTK or WX threading for IPyhton if the
1065 It automatically activates GTK or WX threading for IPyhton if the
1055 choice of matplotlib backend requires it. It also modifies the
1066 choice of matplotlib backend requires it. It also modifies the
1056 %run command to correctly execute (without blocking) any
1067 %run command to correctly execute (without blocking) any
1057 matplotlib-based script which calls show() at the end. See Sec. 15
1068 matplotlib-based script which calls show() at the end. See Sec. 15
1058 <node15.html#sec:matplotlib-support> for more details.
1069 <node15.html#sec:matplotlib-support> for more details.
1059 * [-autocall] <val>: Make IPython automatically call any callable
1070 * [-autocall] <val>: Make IPython automatically call any callable
1060 object even if you didn't type explicit parentheses. For example,
1071 object even if you didn't type explicit parentheses. For example,
1061 'str 43' becomes 'str(43)' automatically. The value can be '0' to
1072 'str 43' becomes 'str(43)' automatically. The value can be '0' to
1062 disable the feature, '1' for smart autocall, where it is not
1073 disable the feature, '1' for smart autocall, where it is not
1063 applied if there are no more arguments on the line, and '2' for
1074 applied if there are no more arguments on the line, and '2' for
1064 full autocall, where all callable objects are automatically called
1075 full autocall, where all callable objects are automatically called
1065 (even if no arguments are present). The default is '1'.
1076 (even if no arguments are present). The default is '1'.
1066 * [-[no]autoindent:] Turn automatic indentation on/off.
1077 * [-[no]autoindent:] Turn automatic indentation on/off.
1067 * [-[no]automagic:] make magic commands automatic (without needing
1078 * [-[no]automagic:] make magic commands automatic (without needing
1068 their first character to be %). Type %magic at the IPython prompt
1079 their first character to be %). Type %magic at the IPython prompt
1069 for more information.
1080 for more information.
1070 * [-[no]autoedit_syntax:] When a syntax error occurs after editing a
1081 * [-[no]autoedit_syntax:] When a syntax error occurs after editing a
1071 file, automatically open the file to the trouble causing line for
1082 file, automatically open the file to the trouble causing line for
1072 convenient fixing.
1083 convenient fixing.
1073 * [-[no]banner:] Print the initial information banner (default on).
1084 * [-[no]banner:] Print the initial information banner (default on).
1074 * [-c <command>:] execute the given command string, and set sys.argv
1085 * [-c <command>:] execute the given command string, and set sys.argv
1075 to ['c']. This is similar to the -c option in the normal Python
1086 to ['c']. This is similar to the -c option in the normal Python
1076 interpreter.
1087 interpreter.
1077 * [-cache_size|cs <n>:] size of the output cache (maximum number of
1088 * [-cache_size|cs <n>:] size of the output cache (maximum number of
1078 entries to hold in memory). The default is 1000, you can change it
1089 entries to hold in memory). The default is 1000, you can change it
1079 permanently in your config file. Setting it to 0 completely
1090 permanently in your config file. Setting it to 0 completely
1080 disables the caching system, and the minimum value accepted is 20
1091 disables the caching system, and the minimum value accepted is 20
1081 (if you provide a value less than 20, it is reset to 0 and a
1092 (if you provide a value less than 20, it is reset to 0 and a
1082 warning is issued) This limit is defined because otherwise you'll
1093 warning is issued) This limit is defined because otherwise you'll
1083 spend more time re-flushing a too small cache than working.
1094 spend more time re-flushing a too small cache than working.
1084 * [-classic|cl:] Gives IPython a similar feel to the classic Python
1095 * [-classic|cl:] Gives IPython a similar feel to the classic Python
1085 prompt.
1096 prompt.
1086 * [-colors <scheme>:] Color scheme for prompts and exception
1097 * [-colors <scheme>:] Color scheme for prompts and exception
1087 reporting. Currently implemented: NoColor, Linux and LightBG.
1098 reporting. Currently implemented: NoColor, Linux and LightBG.
1088 * [-[no]color_info:] IPython can display information about objects
1099 * [-[no]color_info:] IPython can display information about objects
1089 via a set of functions, and optionally can use colors for this,
1100 via a set of functions, and optionally can use colors for this,
1090 syntax highlighting source code and various other elements.
1101 syntax highlighting source code and various other elements.
1091 However, because this information is passed through a pager (like
1102 However, because this information is passed through a pager (like
1092 'less') and many pagers get confused with color codes, this option
1103 'less') and many pagers get confused with color codes, this option
1093 is off by default. You can test it and turn it on permanently in
1104 is off by default. You can test it and turn it on permanently in
1094 your ipythonrc file if it works for you. As a reference, the
1105 your ipythonrc file if it works for you. As a reference, the
1095 'less' pager supplied with Mandrake 8.2 works ok, but that in
1106 'less' pager supplied with Mandrake 8.2 works ok, but that in
1096 RedHat 7.2 doesn't.
1107 RedHat 7.2 doesn't.
1097 * [ ] Test it and turn it on permanently if it works with your
1108 * [ ] Test it and turn it on permanently if it works with your
1098 system. The magic function %color_info allows you to toggle this
1109 system. The magic function %color_info allows you to toggle this
1099 interactively for testing.
1110 interactively for testing.
1100 * [-[no]debug:] Show information about the loading process. Very
1111 * [-[no]debug:] Show information about the loading process. Very
1101 useful to pin down problems with your configuration files or to
1112 useful to pin down problems with your configuration files or to
1102 get details about session restores.
1113 get details about session restores.
1103 * [-[no]deep_reload:] IPython can use the deep_reload module which
1114 * [-[no]deep_reload:] IPython can use the deep_reload module which
1104 reloads changes in modules recursively (it replaces the reload()
1115 reloads changes in modules recursively (it replaces the reload()
1105 function, so you don't need to change anything to use it).
1116 function, so you don't need to change anything to use it).
1106 deep_reload() forces a full reload of modules whose code may have
1117 deep_reload() forces a full reload of modules whose code may have
1107 changed, which the default reload() function does not.
1118 changed, which the default reload() function does not.
1108 * [ ] When deep_reload is off, IPython will use the normal reload(),
1119 * [ ] When deep_reload is off, IPython will use the normal reload(),
1109 but deep_reload will still be available as dreload(). This feature
1120 but deep_reload will still be available as dreload(). This feature
1110 is off by default [which means that you have both normal reload()
1121 is off by default [which means that you have both normal reload()
1111 and dreload()].
1122 and dreload()].
1112 * [-editor <name>:] Which editor to use with the %edit command. By
1123 * [-editor <name>:] Which editor to use with the %edit command. By
1113 default, IPython will honor your EDITOR environment variable (if
1124 default, IPython will honor your EDITOR environment variable (if
1114 not set, vi is the Unix default and notepad the Windows one).
1125 not set, vi is the Unix default and notepad the Windows one).
1115 Since this editor is invoked on the fly by IPython and is meant
1126 Since this editor is invoked on the fly by IPython and is meant
1116 for editing small code snippets, you may want to use a small,
1127 for editing small code snippets, you may want to use a small,
1117 lightweight editor here (in case your default EDITOR is something
1128 lightweight editor here (in case your default EDITOR is something
1118 like Emacs).
1129 like Emacs).
1119 * [-ipythondir <name>:] name of your IPython configuration directory
1130 * [-ipythondir <name>:] name of your IPython configuration directory
1120 IPYTHONDIR. This can also be specified through the environment
1131 IPYTHONDIR. This can also be specified through the environment
1121 variable IPYTHONDIR.
1132 variable IPYTHONDIR.
1122 * [-log|l:] generate a log file of all input. The file is named
1133 * [-log|l:] generate a log file of all input. The file is named
1123 ipython_log.py in your current directory (which prevents logs from
1134 ipython_log.py in your current directory (which prevents logs from
1124 multiple IPython sessions from trampling each other). You can use
1135 multiple IPython sessions from trampling each other). You can use
1125 this to later restore a session by loading your logfile as a file
1136 this to later restore a session by loading your logfile as a file
1126 to be executed with option -logplay (see below).
1137 to be executed with option -logplay (see below).
1127 * [-logfile|lf <name>:] specify the name of your logfile.
1138 * [-logfile|lf <name>:] specify the name of your logfile.
1128 * [-logplay|lp <name>:] you can replay a previous log. For restoring
1139 * [-logplay|lp <name>:] you can replay a previous log. For restoring
1129 a session as close as possible to the state you left it in, use
1140 a session as close as possible to the state you left it in, use
1130 this option (don't just run the logfile). With -logplay, IPython
1141 this option (don't just run the logfile). With -logplay, IPython
1131 will try to reconstruct the previous working environment in full,
1142 will try to reconstruct the previous working environment in full,
1132 not just execute the commands in the logfile.
1143 not just execute the commands in the logfile.
1133 * [ ] When a session is restored, logging is automatically turned on
1144 * [ ] When a session is restored, logging is automatically turned on
1134 again with the name of the logfile it was invoked with (it is read
1145 again with the name of the logfile it was invoked with (it is read
1135 from the log header). So once you've turned logging on for a
1146 from the log header). So once you've turned logging on for a
1136 session, you can quit IPython and reload it as many times as you
1147 session, you can quit IPython and reload it as many times as you
1137 want and it will continue to log its history and restore from the
1148 want and it will continue to log its history and restore from the
1138 beginning every time.
1149 beginning every time.
1139 * [ ] Caveats: there are limitations in this option. The history
1150 * [ ] Caveats: there are limitations in this option. The history
1140 variables _i*,_* and _dh don't get restored properly. In the
1151 variables _i*,_* and _dh don't get restored properly. In the
1141 future we will try to implement full session saving by writing and
1152 future we will try to implement full session saving by writing and
1142 retrieving a 'snapshot' of the memory state of IPython. But our
1153 retrieving a 'snapshot' of the memory state of IPython. But our
1143 first attempts failed because of inherent limitations of Python's
1154 first attempts failed because of inherent limitations of Python's
1144 Pickle module, so this may have to wait.
1155 Pickle module, so this may have to wait.
1145 * [-[no]messages:] Print messages which IPython collects about its
1156 * [-[no]messages:] Print messages which IPython collects about its
1146 startup process (default on).
1157 startup process (default on).
1147 * [-[no]pdb:] Automatically call the pdb debugger after every
1158 * [-[no]pdb:] Automatically call the pdb debugger after every
1148 uncaught exception. If you are used to debugging using pdb, this
1159 uncaught exception. If you are used to debugging using pdb, this
1149 puts you automatically inside of it after any call (either in
1160 puts you automatically inside of it after any call (either in
1150 IPython or in code called by it) which triggers an exception which
1161 IPython or in code called by it) which triggers an exception which
1151 goes uncaught.
1162 goes uncaught.
1152 * [-[no]pprint:] ipython can optionally use the pprint (pretty
1163 * [-[no]pprint:] ipython can optionally use the pprint (pretty
1153 printer) module for displaying results. pprint tends to give a
1164 printer) module for displaying results. pprint tends to give a
1154 nicer display of nested data structures. If you like it, you can
1165 nicer display of nested data structures. If you like it, you can
1155 turn it on permanently in your config file (default off).
1166 turn it on permanently in your config file (default off).
1156 * [-profile|p] <name>: assume that your config file is
1167 * [-profile|p] <name>: assume that your config file is
1157 ipythonrc-<name> (looks in current dir first, then in IPYTHONDIR).
1168 ipythonrc-<name> (looks in current dir first, then in IPYTHONDIR).
1158 This is a quick way to keep and load multiple config files for
1169 This is a quick way to keep and load multiple config files for
1159 different tasks, especially if you use the include option of
1170 different tasks, especially if you use the include option of
1160 config files. You can keep a basic IPYTHONDIR/ipythonrc file and
1171 config files. You can keep a basic IPYTHONDIR/ipythonrc file and
1161 then have other 'profiles' which include this one and load extra
1172 then have other 'profiles' which include this one and load extra
1162 things for particular tasks. For example:
1173 things for particular tasks. For example:
1163 * [ ] 1. $HOME/.ipython/ipythonrc : load basic things you always want.
1174 * [ ] 1. $HOME/.ipython/ipythonrc : load basic things you always want.
1164 * [ ] 2. $HOME/.ipython/ipythonrc-math : load (1) and basic
1175 * [ ] 2. $HOME/.ipython/ipythonrc-math : load (1) and basic
1165 math-related modules.
1176 math-related modules.
1166 * [ ] 3. $HOME/.ipython/ipythonrc-numeric : load (1) and Numeric and
1177 * [ ] 3. $HOME/.ipython/ipythonrc-numeric : load (1) and Numeric and
1167 plotting modules.
1178 plotting modules.
1168 * [ ] Since it is possible to create an endless loop by having
1179 * [ ] Since it is possible to create an endless loop by having
1169 circular file inclusions, IPython will stop if it reaches 15
1180 circular file inclusions, IPython will stop if it reaches 15
1170 recursive inclusions.
1181 recursive inclusions.
1171 * [-prompt_in1|pi1 <string>:] Specify the string used for input
1182 * [-prompt_in1|pi1 <string>:] Specify the string used for input
1172 prompts. Note that if you are using numbered prompts, the number
1183 prompts. Note that if you are using numbered prompts, the number
1173 is represented with a '\#' in the string. Don't forget to quote
1184 is represented with a '\#' in the string. Don't forget to quote
1174 strings with spaces embedded in them. Default: 'In [\#]:'.
1185 strings with spaces embedded in them. Default: 'In [\#]:'.
1175 Sec. 7.2 <node7.html#sec:prompts> discusses in detail all the
1186 Sec. 7.2 <node7.html#sec:prompts> discusses in detail all the
1176 available escapes to customize your prompts.
1187 available escapes to customize your prompts.
1177 * [-prompt_in2|pi2 <string>:] Similar to the previous option, but
1188 * [-prompt_in2|pi2 <string>:] Similar to the previous option, but
1178 used for the continuation prompts. The special sequence '\D' is
1189 used for the continuation prompts. The special sequence '\D' is
1179 similar to '\#', but with all digits replaced dots (so you can
1190 similar to '\#', but with all digits replaced dots (so you can
1180 have your continuation prompt aligned with your input prompt).
1191 have your continuation prompt aligned with your input prompt).
1181 Default: ' .\D.:' (note three spaces at the start for alignment
1192 Default: ' .\D.:' (note three spaces at the start for alignment
1182 with 'In [\#]').
1193 with 'In [\#]').
1183 * [-prompt_out|po <string>:] String used for output prompts, also
1194 * [-prompt_out|po <string>:] String used for output prompts, also
1184 uses numbers like prompt_in1. Default: 'Out[\#]:'
1195 uses numbers like prompt_in1. Default: 'Out[\#]:'
1185 * [-quick:] start in bare bones mode (no config file loaded).
1196 * [-quick:] start in bare bones mode (no config file loaded).
1186 * [-rcfile <name>:] name of your IPython resource configuration
1197 * [-rcfile <name>:] name of your IPython resource configuration
1187 file. Normally IPython loads ipythonrc (from current directory) or
1198 file. Normally IPython loads ipythonrc (from current directory) or
1188 IPYTHONDIR/ipythonrc.
1199 IPYTHONDIR/ipythonrc.
1189 * [ ] If the loading of your config file fails, IPython starts with
1200 * [ ] If the loading of your config file fails, IPython starts with
1190 a bare bones configuration (no modules loaded at all).
1201 a bare bones configuration (no modules loaded at all).
1191 * [-[no]readline:] use the readline library, which is needed to
1202 * [-[no]readline:] use the readline library, which is needed to
1192 support name completion and command history, among other things.
1203 support name completion and command history, among other things.
1193 It is enabled by default, but may cause problems for users of
1204 It is enabled by default, but may cause problems for users of
1194 X/Emacs in Python comint or shell buffers.
1205 X/Emacs in Python comint or shell buffers.
1195 * [ ] Note that X/Emacs 'eterm' buffers (opened with M-x term)
1206 * [ ] Note that X/Emacs 'eterm' buffers (opened with M-x term)
1196 support IPython's readline and syntax coloring fine, only 'emacs'
1207 support IPython's readline and syntax coloring fine, only 'emacs'
1197 (M-x shell and C-c !) buffers do not.
1208 (M-x shell and C-c !) buffers do not.
1198 * [-screen_length|sl <n>:] number of lines of your screen. This is
1209 * [-screen_length|sl <n>:] number of lines of your screen. This is
1199 used to control printing of very long strings. Strings longer than
1210 used to control printing of very long strings. Strings longer than
1200 this number of lines will be sent through a pager instead of
1211 this number of lines will be sent through a pager instead of
1201 directly printed.
1212 directly printed.
1202 * [ ] The default value for this is 0, which means IPython will
1213 * [ ] The default value for this is 0, which means IPython will
1203 auto-detect your screen size every time it needs to print certain
1214 auto-detect your screen size every time it needs to print certain
1204 potentially long strings (this doesn't change the behavior of the
1215 potentially long strings (this doesn't change the behavior of the
1205 'print' keyword, it's only triggered internally). If for some
1216 'print' keyword, it's only triggered internally). If for some
1206 reason this isn't working well (it needs curses support), specify
1217 reason this isn't working well (it needs curses support), specify
1207 it yourself. Otherwise don't change the default.
1218 it yourself. Otherwise don't change the default.
1208 * [-separate_in|si <string>:] separator before input prompts.
1219 * [-separate_in|si <string>:] separator before input prompts.
1209 Default: '\n'
1220 Default: '\n'
1210 * [-separate_out|so <string>:] separator before output prompts.
1221 * [-separate_out|so <string>:] separator before output prompts.
1211 Default: nothing.
1222 Default: nothing.
1212 * [-separate_out2|so2 <string>:] separator after output prompts.
1223 * [-separate_out2|so2 <string>:] separator after output prompts.
1213 Default: nothing.
1224 Default: nothing.
1214 * [ ] For these three options, use the value 0 to specify no separator.
1225 * [ ] For these three options, use the value 0 to specify no separator.
1215 * [-nosep:] shorthand for '-SeparateIn 0 -SeparateOut 0
1226 * [-nosep:] shorthand for '-SeparateIn 0 -SeparateOut 0
1216 -SeparateOut2 0'. Simply removes all input/output separators.
1227 -SeparateOut2 0'. Simply removes all input/output separators.
1217 * [-upgrade:] allows you to upgrade your IPYTHONDIR configuration
1228 * [-upgrade:] allows you to upgrade your IPYTHONDIR configuration
1218 when you install a new version of IPython. Since new versions may
1229 when you install a new version of IPython. Since new versions may
1219 include new command line options or example files, this copies
1230 include new command line options or example files, this copies
1220 updated ipythonrc-type files. However, it backs up (with a .old
1231 updated ipythonrc-type files. However, it backs up (with a .old
1221 extension) all files which it overwrites so that you can merge
1232 extension) all files which it overwrites so that you can merge
1222 back any customizations you might have in your personal files.
1233 back any customizations you might have in your personal files.
1223 * [-Version:] print version information and exit.
1234 * [-Version:] print version information and exit.
1224 * [-wxversion <string>:] Select a specific version of wxPython (used
1235 * [-wxversion <string>:] Select a specific version of wxPython (used
1225 in conjunction with -wthread). Requires the wxversion module, part
1236 in conjunction with -wthread). Requires the wxversion module, part
1226 of recent wxPython distributions
1237 of recent wxPython distributions
1227 * [-xmode <modename>:] Mode for exception reporting.
1238 * [-xmode <modename>:] Mode for exception reporting.
1228 * [ ] Valid modes: Plain, Context and Verbose.
1239 * [ ] Valid modes: Plain, Context and Verbose.
1229 * [ ] Plain: similar to python's normal traceback printing.
1240 * [ ] Plain: similar to python's normal traceback printing.
1230 * [ ] Context: prints 5 lines of context source code around each
1241 * [ ] Context: prints 5 lines of context source code around each
1231 line in the traceback.
1242 line in the traceback.
1232 * [ ] Verbose: similar to Context, but additionally prints the
1243 * [ ] Verbose: similar to Context, but additionally prints the
1233 variables currently visible where the exception happened
1244 variables currently visible where the exception happened
1234 (shortening their strings if too long). This can potentially be
1245 (shortening their strings if too long). This can potentially be
1235 very slow, if you happen to have a huge data structure whose
1246 very slow, if you happen to have a huge data structure whose
1236 string representation is complex to compute. Your computer may
1247 string representation is complex to compute. Your computer may
1237 appear to freeze for a while with cpu usage at 100%. If this
1248 appear to freeze for a while with cpu usage at 100%. If this
1238 occurs, you can cancel the traceback with Ctrl-C (maybe hitting it
1249 occurs, you can cancel the traceback with Ctrl-C (maybe hitting it
1239 more than once).
1250 more than once).
1240
1251
1241 Interactive use
1252 Interactive use
1242 ===============
1253 ===============
1243
1254
1244 Warning: IPython relies on the existence of a global variable called
1255 Warning: IPython relies on the existence of a global variable called
1245 __IP which controls the shell itself. If you redefine __IP to anything,
1256 __IP which controls the shell itself. If you redefine __IP to anything,
1246 bizarre behavior will quickly occur.
1257 bizarre behavior will quickly occur.
1247
1258
1248 Other than the above warning, IPython is meant to work as a drop-in
1259 Other than the above warning, IPython is meant to work as a drop-in
1249 replacement for the standard interactive interpreter. As such, any code
1260 replacement for the standard interactive interpreter. As such, any code
1250 which is valid python should execute normally under IPython (cases where
1261 which is valid python should execute normally under IPython (cases where
1251 this is not true should be reported as bugs). It does, however, offer
1262 this is not true should be reported as bugs). It does, however, offer
1252 many features which are not available at a standard python prompt. What
1263 many features which are not available at a standard python prompt. What
1253 follows is a list of these.
1264 follows is a list of these.
1254
1265
1255
1266
1256 Caution for Windows users
1267 Caution for Windows users
1257 -------------------------
1268 -------------------------
1258
1269
1259 Windows, unfortunately, uses the '\' character as a path separator. This
1270 Windows, unfortunately, uses the '\' character as a path separator. This
1260 is a terrible choice, because '\' also represents the escape character
1271 is a terrible choice, because '\' also represents the escape character
1261 in most modern programming languages, including Python. For this reason,
1272 in most modern programming languages, including Python. For this reason,
1262 issuing many of the commands discussed below (especially magics which
1273 issuing many of the commands discussed below (especially magics which
1263 affect the filesystem) with '\' in them will cause strange errors.
1274 affect the filesystem) with '\' in them will cause strange errors.
1264
1275
1265 A partial solution is to use instead the '/' character as a path
1276 A partial solution is to use instead the '/' character as a path
1266 separator, which Windows recognizes in most situations. However, in
1277 separator, which Windows recognizes in most situations. However, in
1267 Windows commands '/' flags options, so you can not use it for the root
1278 Windows commands '/' flags options, so you can not use it for the root
1268 directory. This means that paths beginning at the root must be typed in
1279 directory. This means that paths beginning at the root must be typed in
1269 a contrived manner like:
1280 a contrived manner like:
1270 %copy \opt/foo/bar.txt \tmp
1281 %copy \opt/foo/bar.txt \tmp
1271
1282
1272 There is no sensible thing IPython can do to truly work around this flaw
1283 There is no sensible thing IPython can do to truly work around this flaw
1273 in Windows^3 <footnode.html#foot878>.
1284 in Windows^3 <footnode.html#foot878>.
1274
1285
1275
1286
1276
1287
1277 Magic command system
1288 Magic command system
1278 --------------------
1289 --------------------
1279
1290
1280 IPython will treat any line whose first character is a % as a special
1291 IPython will treat any line whose first character is a % as a special
1281 call to a 'magic' function. These allow you to control the behavior of
1292 call to a 'magic' function. These allow you to control the behavior of
1282 IPython itself, plus a lot of system-type features. They are all
1293 IPython itself, plus a lot of system-type features. They are all
1283 prefixed with a % character, but parameters are given without
1294 prefixed with a % character, but parameters are given without
1284 parentheses or quotes.
1295 parentheses or quotes.
1285
1296
1286 Example: typing '%cd mydir' (without the quotes) changes you working
1297 Example: typing '%cd mydir' (without the quotes) changes you working
1287 directory to 'mydir', if it exists.
1298 directory to 'mydir', if it exists.
1288
1299
1289 If you have 'automagic' enabled (in your ipythonrc file, via the command
1300 If you have 'automagic' enabled (in your ipythonrc file, via the command
1290 line option -automagic or with the %automagic function), you don't need
1301 line option -automagic or with the %automagic function), you don't need
1291 to type in the % explicitly. IPython will scan its internal list of
1302 to type in the % explicitly. IPython will scan its internal list of
1292 magic functions and call one if it exists. With automagic on you can
1303 magic functions and call one if it exists. With automagic on you can
1293 then just type 'cd mydir' to go to directory 'mydir'. The automagic
1304 then just type 'cd mydir' to go to directory 'mydir'. The automagic
1294 system has the lowest possible precedence in name searches, so defining
1305 system has the lowest possible precedence in name searches, so defining
1295 an identifier with the same name as an existing magic function will
1306 an identifier with the same name as an existing magic function will
1296 shadow it for automagic use. You can still access the shadowed magic
1307 shadow it for automagic use. You can still access the shadowed magic
1297 function by explicitly using the % character at the beginning of the line.
1308 function by explicitly using the % character at the beginning of the line.
1298
1309
1299 An example (with automagic on) should clarify all this::
1310 An example (with automagic on) should clarify all this::
1300
1311
1301 In [1]: cd ipython # %cd is called by automagic
1312 In [1]: cd ipython # %cd is called by automagic
1302
1313
1303 /home/fperez/ipython
1314 /home/fperez/ipython
1304
1315
1305 In [2]: cd=1 # now cd is just a variable
1316 In [2]: cd=1 # now cd is just a variable
1306
1317
1307 In [3]: cd .. # and doesn't work as a function anymore
1318 In [3]: cd .. # and doesn't work as a function anymore
1308
1319
1309 ------------------------------
1320 ------------------------------
1310
1321
1311 File "<console>", line 1
1322 File "<console>", line 1
1312
1323
1313 cd ..
1324 cd ..
1314
1325
1315 ^
1326 ^
1316
1327
1317 SyntaxError: invalid syntax
1328 SyntaxError: invalid syntax
1318
1329
1319 In [4]: %cd .. # but %cd always works
1330 In [4]: %cd .. # but %cd always works
1320
1331
1321 /home/fperez
1332 /home/fperez
1322
1333
1323 In [5]: del cd # if you remove the cd variable
1334 In [5]: del cd # if you remove the cd variable
1324
1335
1325 In [6]: cd ipython # automagic can work again
1336 In [6]: cd ipython # automagic can work again
1326
1337
1327 /home/fperez/ipython
1338 /home/fperez/ipython
1328
1339
1329 You can define your own magic functions to extend the system. The
1340 You can define your own magic functions to extend the system. The
1330 following example defines a new magic command, %impall::
1341 following example defines a new magic command, %impall::
1331
1342
1332 import IPython.ipapi
1343 import IPython.ipapi
1333
1344
1334 ip = IPython.ipapi.get()
1345 ip = IPython.ipapi.get()
1335
1346
1336 def doimp(self, arg):
1347 def doimp(self, arg):
1337
1348
1338 ip = self.api
1349 ip = self.api
1339
1350
1340 ip.ex("import %s; reload(%s); from %s import *" % (
1351 ip.ex("import %s; reload(%s); from %s import *" % (
1341
1352
1342 arg,arg,arg)
1353 arg,arg,arg)
1343
1354
1344 )
1355 )
1345
1356
1346 ip.expose_magic('impall', doimp)
1357 ip.expose_magic('impall', doimp)
1347
1358
1348 You can also define your own aliased names for magic functions. In your
1359 You can also define your own aliased names for magic functions. In your
1349 ipythonrc file, placing a line like:
1360 ipythonrc file, placing a line like:
1350
1361
1351 execute __IP.magic_cl = __IP.magic_clear
1362 execute __IP.magic_cl = __IP.magic_clear
1352
1363
1353 will define %cl as a new name for %clear.
1364 will define %cl as a new name for %clear.
1354
1365
1355 Type %magic for more information, including a list of all available
1366 Type %magic for more information, including a list of all available
1356 magic functions at any time and their docstrings. You can also type
1367 magic functions at any time and their docstrings. You can also type
1357 %magic_function_name? (see sec. 6.4 <#sec:dyn-object-info> for
1368 %magic_function_name? (see sec. 6.4 <#sec:dyn-object-info> for
1358 information on the '?' system) to get information about any particular
1369 information on the '?' system) to get information about any particular
1359 magic function you are interested in.
1370 magic function you are interested in.
1360
1371
1361
1372
1362 Magic commands
1373 Magic commands
1363 --------------
1374 --------------
1364
1375
1365 The rest of this section is automatically generated for each release
1376 The rest of this section is automatically generated for each release
1366 from the docstrings in the IPython code. Therefore the formatting is
1377 from the docstrings in the IPython code. Therefore the formatting is
1367 somewhat minimal, but this method has the advantage of having
1378 somewhat minimal, but this method has the advantage of having
1368 information always in sync with the code.
1379 information always in sync with the code.
1369
1380
1370 A list of all the magic commands available in IPython's default
1381 A list of all the magic commands available in IPython's default
1371 installation follows. This is similar to what you'll see by simply
1382 installation follows. This is similar to what you'll see by simply
1372 typing %magic at the prompt, but that will also give you information
1383 typing %magic at the prompt, but that will also give you information
1373 about magic commands you may have added as part of your personal
1384 about magic commands you may have added as part of your personal
1374 customizations.
1385 customizations.
1375
1386
1376 ::
1387 ::
1377
1388
1378 %Exit: Exit IPython without confirmation.
1389 %Exit: Exit IPython without confirmation.
1379
1390
1380
1391
1381 %Pprint: Toggle pretty printing on/off.
1392 %Pprint: Toggle pretty printing on/off.
1382
1393
1383
1394
1384 %alias: Define an alias for a system command.
1395 %alias: Define an alias for a system command.
1385
1396
1386 '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
1397 '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
1387
1398
1388 Then, typing 'alias_name params' will execute the system command 'cmd
1399 Then, typing 'alias_name params' will execute the system command 'cmd
1389 params' (from your underlying operating system).
1400 params' (from your underlying operating system).
1390
1401
1391 Aliases have lower precedence than magic functions and Python normal
1402 Aliases have lower precedence than magic functions and Python normal
1392 variables, so if 'foo' is both a Python variable and an alias, the alias
1403 variables, so if 'foo' is both a Python variable and an alias, the alias
1393 can not be executed until 'del foo' removes the Python variable.
1404 can not be executed until 'del foo' removes the Python variable.
1394
1405
1395 You can use the %l specifier in an alias definition to represent the
1406 You can use the %l specifier in an alias definition to represent the
1396 whole line when the alias is called. For example:
1407 whole line when the alias is called. For example:
1397
1408
1398 In [2]: alias all echo "Input in brackets: <%l>"
1409 In [2]: alias all echo "Input in brackets: <%l>"
1399 In [3]: all hello world
1410 In [3]: all hello world
1400 Input in brackets: <hello world>
1411 Input in brackets: <hello world>
1401
1412
1402 You can also define aliases with parameters using %s specifiers (one per
1413 You can also define aliases with parameters using %s specifiers (one per
1403 parameter):
1414 parameter):
1404
1415
1405 In [1]: alias parts echo first %s second %s
1416 In [1]: alias parts echo first %s second %s
1406 In [2]: %parts A B
1417 In [2]: %parts A B
1407 first A second B
1418 first A second B
1408 In [3]: %parts A
1419 In [3]: %parts A
1409 Incorrect number of arguments: 2 expected.
1420 Incorrect number of arguments: 2 expected.
1410 parts is an alias to: 'echo first %s second %s'
1421 parts is an alias to: 'echo first %s second %s'
1411
1422
1412 Note that %l and %s are mutually exclusive. You can only use one or the
1423 Note that %l and %s are mutually exclusive. You can only use one or the
1413 other in your aliases.
1424 other in your aliases.
1414
1425
1415 Aliases expand Python variables just like system calls using ! or !! do:
1426 Aliases expand Python variables just like system calls using ! or !! do:
1416 all expressions prefixed with '$' get expanded. For details of the
1427 all expressions prefixed with '$' get expanded. For details of the
1417 semantic rules, see PEP-215: http://www.python.org/peps/pep-0215.html.
1428 semantic rules, see PEP-215: http://www.python.org/peps/pep-0215.html.
1418 This is the library used by IPython for variable expansion. If you want
1429 This is the library used by IPython for variable expansion. If you want
1419 to access a true shell variable, an extra $ is necessary to prevent its
1430 to access a true shell variable, an extra $ is necessary to prevent its
1420 expansion by IPython:
1431 expansion by IPython:
1421
1432
1422 In [6]: alias show echo
1433 In [6]: alias show echo
1423 In [7]: PATH='A Python string'
1434 In [7]: PATH='A Python string'
1424 In [8]: show $PATH
1435 In [8]: show $PATH
1425 A Python string
1436 A Python string
1426 In [9]: show $$PATH
1437 In [9]: show $$PATH
1427 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
1438 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
1428
1439
1429 You can use the alias facility to acess all of $PATH. See the %rehash
1440 You can use the alias facility to acess all of $PATH. See the %rehash
1430 and %rehashx functions, which automatically create aliases for the
1441 and %rehashx functions, which automatically create aliases for the
1431 contents of your $PATH.
1442 contents of your $PATH.
1432
1443
1433 If called with no parameters, %alias prints the current alias table.
1444 If called with no parameters, %alias prints the current alias table.
1434
1445
1435
1446
1436 %autocall: Make functions callable without having to type parentheses.
1447 %autocall: Make functions callable without having to type parentheses.
1437
1448
1438 Usage:
1449 Usage:
1439
1450
1440 %autocall [mode]
1451 %autocall [mode]
1441
1452
1442 The mode can be one of: 0->Off, 1->Smart, 2->Full. If not given, the
1453 The mode can be one of: 0->Off, 1->Smart, 2->Full. If not given, the
1443 value is toggled on and off (remembering the previous state).
1454 value is toggled on and off (remembering the previous state).
1444
1455
1445 In more detail, these values mean:
1456 In more detail, these values mean:
1446
1457
1447 0 -> fully disabled
1458 0 -> fully disabled
1448
1459
1449 1 -> active, but do not apply if there are no arguments on the line.
1460 1 -> active, but do not apply if there are no arguments on the line.
1450
1461
1451 In this mode, you get:
1462 In this mode, you get:
1452
1463
1453 In [1]: callable Out[1]: <built-in function callable>
1464 In [1]: callable Out[1]: <built-in function callable>
1454
1465
1455 In [2]: callable 'hello' ---> callable('hello') Out[2]: False
1466 In [2]: callable 'hello' ---> callable('hello') Out[2]: False
1456
1467
1457 2 -> Active always. Even if no arguments are present, the callable
1468 2 -> Active always. Even if no arguments are present, the callable
1458 object is called:
1469 object is called:
1459
1470
1460 In [4]: callable ---> callable()
1471 In [4]: callable ---> callable()
1461
1472
1462 Note that even with autocall off, you can still use '/' at the start of
1473 Note that even with autocall off, you can still use '/' at the start of
1463 a line to treat the first argument on the command line as a function and
1474 a line to treat the first argument on the command line as a function and
1464 add parentheses to it:
1475 add parentheses to it:
1465
1476
1466 In [8]: /str 43 ---> str(43) Out[8]: '43'
1477 In [8]: /str 43 ---> str(43) Out[8]: '43'
1467
1478
1468
1479
1469 %autoindent: Toggle autoindent on/off (if available).
1480 %autoindent: Toggle autoindent on/off (if available).
1470
1481
1471
1482
1472 %automagic: Make magic functions callable without having to type the
1483 %automagic: Make magic functions callable without having to type the
1473 initial %.
1484 initial %.
1474
1485
1475 Without argumentsl toggles on/off (when off, you must call it as
1486 Without argumentsl toggles on/off (when off, you must call it as
1476 %automagic, of course). With arguments it sets the value, and you can
1487 %automagic, of course). With arguments it sets the value, and you can
1477 use any of (case insensitive):
1488 use any of (case insensitive):
1478
1489
1479 - on,1,True: to activate
1490 - on,1,True: to activate
1480
1491
1481 - off,0,False: to deactivate.
1492 - off,0,False: to deactivate.
1482
1493
1483 Note that magic functions have lowest priority, so if there's a variable
1494 Note that magic functions have lowest priority, so if there's a variable
1484 whose name collides with that of a magic fn, automagic won't work for
1495 whose name collides with that of a magic fn, automagic won't work for
1485 that function (you get the variable instead). However, if you delete the
1496 that function (you get the variable instead). However, if you delete the
1486 variable (del var), the previously shadowed magic function becomes
1497 variable (del var), the previously shadowed magic function becomes
1487 visible to automagic again.
1498 visible to automagic again.
1488
1499
1489
1500
1490 %bg: Run a job in the background, in a separate thread.
1501 %bg: Run a job in the background, in a separate thread.
1491
1502
1492 For example,
1503 For example,
1493
1504
1494 %bg myfunc(x,y,z=1)
1505 %bg myfunc(x,y,z=1)
1495
1506
1496 will execute 'myfunc(x,y,z=1)' in a background thread. As soon as the
1507 will execute 'myfunc(x,y,z=1)' in a background thread. As soon as the
1497 execution starts, a message will be printed indicating the job number.
1508 execution starts, a message will be printed indicating the job number.
1498 If your job number is 5, you can use
1509 If your job number is 5, you can use
1499
1510
1500 myvar = jobs.result(5) or myvar = jobs[5].result
1511 myvar = jobs.result(5) or myvar = jobs[5].result
1501
1512
1502 to assign this result to variable 'myvar'.
1513 to assign this result to variable 'myvar'.
1503
1514
1504 IPython has a job manager, accessible via the 'jobs' object. You can
1515 IPython has a job manager, accessible via the 'jobs' object. You can
1505 type jobs? to get more information about it, and use jobs.<TAB> to see
1516 type jobs? to get more information about it, and use jobs.<TAB> to see
1506 its attributes. All attributes not starting with an underscore are meant
1517 its attributes. All attributes not starting with an underscore are meant
1507 for public use.
1518 for public use.
1508
1519
1509 In particular, look at the jobs.new() method, which is used to create
1520 In particular, look at the jobs.new() method, which is used to create
1510 new jobs. This magic %bg function is just a convenience wrapper around
1521 new jobs. This magic %bg function is just a convenience wrapper around
1511 jobs.new(), for expression-based jobs. If you want to create a new job
1522 jobs.new(), for expression-based jobs. If you want to create a new job
1512 with an explicit function object and arguments, you must call jobs.new()
1523 with an explicit function object and arguments, you must call jobs.new()
1513 directly.
1524 directly.
1514
1525
1515 The jobs.new docstring also describes in detail several important
1526 The jobs.new docstring also describes in detail several important
1516 caveats associated with a thread-based model for background job
1527 caveats associated with a thread-based model for background job
1517 execution. Type jobs.new? for details.
1528 execution. Type jobs.new? for details.
1518
1529
1519 You can check the status of all jobs with jobs.status().
1530 You can check the status of all jobs with jobs.status().
1520
1531
1521 The jobs variable is set by IPython into the Python builtin namespace.
1532 The jobs variable is set by IPython into the Python builtin namespace.
1522 If you ever declare a variable named 'jobs', you will shadow this name.
1533 If you ever declare a variable named 'jobs', you will shadow this name.
1523 You can either delete your global jobs variable to regain access to the
1534 You can either delete your global jobs variable to regain access to the
1524 job manager, or make a new name and assign it manually to the manager
1535 job manager, or make a new name and assign it manually to the manager
1525 (stored in IPython's namespace). For example, to assign the job manager
1536 (stored in IPython's namespace). For example, to assign the job manager
1526 to the Jobs name, use:
1537 to the Jobs name, use:
1527
1538
1528 Jobs = __builtins__.jobs
1539 Jobs = __builtins__.jobs
1529
1540
1530
1541
1531 %bookmark: Manage IPython's bookmark system.
1542 %bookmark: Manage IPython's bookmark system.
1532
1543
1533 %bookmark <name> - set bookmark to current dir %bookmark <name> <dir> -
1544 %bookmark <name> - set bookmark to current dir %bookmark <name> <dir> -
1534 set bookmark to <dir> %bookmark -l - list all bookmarks %bookmark -d
1545 set bookmark to <dir> %bookmark -l - list all bookmarks %bookmark -d
1535 <name> - remove bookmark %bookmark -r - remove all bookmarks
1546 <name> - remove bookmark %bookmark -r - remove all bookmarks
1536
1547
1537 You can later on access a bookmarked folder with: %cd -b <name> or
1548 You can later on access a bookmarked folder with: %cd -b <name> or
1538 simply '%cd <name>' if there is no directory called <name> AND there is
1549 simply '%cd <name>' if there is no directory called <name> AND there is
1539 such a bookmark defined.
1550 such a bookmark defined.
1540
1551
1541 Your bookmarks persist through IPython sessions, but they are associated
1552 Your bookmarks persist through IPython sessions, but they are associated
1542 with each profile.
1553 with each profile.
1543
1554
1544
1555
1545 %cd: Change the current working directory.
1556 %cd: Change the current working directory.
1546
1557
1547 This command automatically maintains an internal list of directories you
1558 This command automatically maintains an internal list of directories you
1548 visit during your IPython session, in the variable _dh. The command
1559 visit during your IPython session, in the variable _dh. The command
1549 %dhist shows this history nicely formatted. You can also do 'cd -<tab>'
1560 %dhist shows this history nicely formatted. You can also do 'cd -<tab>'
1550 to see directory history conveniently.
1561 to see directory history conveniently.
1551
1562
1552 Usage:
1563 Usage:
1553
1564
1554 cd 'dir': changes to directory 'dir'.
1565 cd 'dir': changes to directory 'dir'.
1555
1566
1556 cd -: changes to the last visited directory.
1567 cd -: changes to the last visited directory.
1557
1568
1558 cd -<n>: changes to the n-th directory in the directory history.
1569 cd -<n>: changes to the n-th directory in the directory history.
1559
1570
1560 cd -b <bookmark_name>: jump to a bookmark set by %bookmark (note: cd
1571 cd -b <bookmark_name>: jump to a bookmark set by %bookmark (note: cd
1561 <bookmark_name> is enough if there is no directory <bookmark_name>, but
1572 <bookmark_name> is enough if there is no directory <bookmark_name>, but
1562 a bookmark with the name exists.) 'cd -b <tab>' allows you to
1573 a bookmark with the name exists.) 'cd -b <tab>' allows you to
1563 tab-complete bookmark names.
1574 tab-complete bookmark names.
1564
1575
1565 Options:
1576 Options:
1566
1577
1567 -q: quiet. Do not print the working directory after the cd command is
1578 -q: quiet. Do not print the working directory after the cd command is
1568 executed. By default IPython's cd command does print this directory,
1579 executed. By default IPython's cd command does print this directory,
1569 since the default prompts do not display path information.
1580 since the default prompts do not display path information.
1570
1581
1571 Note that !cd doesn't work for this purpose because the shell where
1582 Note that !cd doesn't work for this purpose because the shell where
1572 !command runs is immediately discarded after executing 'command'.
1583 !command runs is immediately discarded after executing 'command'.
1573
1584
1574
1585
1575 %color_info: Toggle color_info.
1586 %color_info: Toggle color_info.
1576
1587
1577 The color_info configuration parameter controls whether colors are used
1588 The color_info configuration parameter controls whether colors are used
1578 for displaying object details (by things like %psource, %pfile or the
1589 for displaying object details (by things like %psource, %pfile or the
1579 '?' system). This function toggles this value with each call.
1590 '?' system). This function toggles this value with each call.
1580
1591
1581 Note that unless you have a fairly recent pager (less works better than
1592 Note that unless you have a fairly recent pager (less works better than
1582 more) in your system, using colored object information displays will not
1593 more) in your system, using colored object information displays will not
1583 work properly. Test it and see.
1594 work properly. Test it and see.
1584
1595
1585
1596
1586 %colors: Switch color scheme for prompts, info system and exception
1597 %colors: Switch color scheme for prompts, info system and exception
1587 handlers.
1598 handlers.
1588
1599
1589 Currently implemented schemes: NoColor, Linux, LightBG.
1600 Currently implemented schemes: NoColor, Linux, LightBG.
1590
1601
1591 Color scheme names are not case-sensitive.
1602 Color scheme names are not case-sensitive.
1592
1603
1593
1604
1594 %cpaste: Allows you to paste & execute a pre-formatted code block from
1605 %cpaste: Allows you to paste & execute a pre-formatted code block from
1595 clipboard
1606 clipboard
1596
1607
1597 You must terminate the block with '-' (two minus-signs) alone on the
1608 You must terminate the block with '-' (two minus-signs) alone on the
1598 line. You can also provide your own sentinel with '%paste -s %%' ('%%'
1609 line. You can also provide your own sentinel with '%paste -s %%' ('%%'
1599 is the new sentinel for this operation)
1610 is the new sentinel for this operation)
1600
1611
1601 The block is dedented prior to execution to enable execution of method
1612 The block is dedented prior to execution to enable execution of method
1602 definitions. '>' and '+' characters at the beginning of a line are
1613 definitions. '>' and '+' characters at the beginning of a line are
1603 ignored, to allow pasting directly from e-mails or diff files. The
1614 ignored, to allow pasting directly from e-mails or diff files. The
1604 executed block is also assigned to variable named 'pasted_block' for
1615 executed block is also assigned to variable named 'pasted_block' for
1605 later editing with '%edit pasted_block'.
1616 later editing with '%edit pasted_block'.
1606
1617
1607 You can also pass a variable name as an argument, e.g. '%cpaste foo'.
1618 You can also pass a variable name as an argument, e.g. '%cpaste foo'.
1608 This assigns the pasted block to variable 'foo' as string, without
1619 This assigns the pasted block to variable 'foo' as string, without
1609 dedenting or executing it.
1620 dedenting or executing it.
1610
1621
1611 Do not be alarmed by garbled output on Windows (it's a readline bug).
1622 Do not be alarmed by garbled output on Windows (it's a readline bug).
1612 Just press enter and type - (and press enter again) and the block will
1623 Just press enter and type - (and press enter again) and the block will
1613 be what was just pasted.
1624 be what was just pasted.
1614
1625
1615 IPython statements (magics, shell escapes) are not supported (yet).
1626 IPython statements (magics, shell escapes) are not supported (yet).
1616
1627
1617
1628
1618 %debug: Activate the interactive debugger in post-mortem mode.
1629 %debug: Activate the interactive debugger in post-mortem mode.
1619
1630
1620 If an exception has just occurred, this lets you inspect its stack
1631 If an exception has just occurred, this lets you inspect its stack
1621 frames interactively. Note that this will always work only on the last
1632 frames interactively. Note that this will always work only on the last
1622 traceback that occurred, so you must call this quickly after an
1633 traceback that occurred, so you must call this quickly after an
1623 exception that you wish to inspect has fired, because if another one
1634 exception that you wish to inspect has fired, because if another one
1624 occurs, it clobbers the previous one.
1635 occurs, it clobbers the previous one.
1625
1636
1626 If you want IPython to automatically do this on every exception, see the
1637 If you want IPython to automatically do this on every exception, see the
1627 %pdb magic for more details.
1638 %pdb magic for more details.
1628
1639
1629
1640
1630 %dhist: Print your history of visited directories.
1641 %dhist: Print your history of visited directories.
1631
1642
1632 %dhist -> print full history
1643 %dhist -> print full history
1633 %dhist n -> print last n entries only
1644 %dhist n -> print last n entries only
1634 %dhist n1 n2 -> print entries between n1 and n2 (n1 not included)
1645 %dhist n1 n2 -> print entries between n1 and n2 (n1 not included)
1635
1646
1636 This history is automatically maintained by the %cd command, and always
1647 This history is automatically maintained by the %cd command, and always
1637 available as the global list variable _dh. You can use %cd -<n> to go to
1648 available as the global list variable _dh. You can use %cd -<n> to go to
1638 directory number <n>.
1649 directory number <n>.
1639
1650
1640 Note that most of time, you should view directory history by entering cd
1651 Note that most of time, you should view directory history by entering cd
1641 -<TAB>.
1652 -<TAB>.
1642
1653
1643
1654
1644 %dirs: Return the current directory stack.
1655 %dirs: Return the current directory stack.
1645
1656
1646
1657
1647 %doctest_mode: Toggle doctest mode on and off.
1658 %doctest_mode: Toggle doctest mode on and off.
1648
1659
1649 This mode allows you to toggle the prompt behavior between normal
1660 This mode allows you to toggle the prompt behavior between normal
1650 IPython prompts and ones that are as similar to the default IPython
1661 IPython prompts and ones that are as similar to the default IPython
1651 interpreter as possible.
1662 interpreter as possible.
1652
1663
1653 It also supports the pasting of code snippets that have leading '»>' and
1664 It also supports the pasting of code snippets that have leading '»>' and
1654 '...' prompts in them. This means that you can paste doctests from files
1665 '...' prompts in them. This means that you can paste doctests from files
1655 or docstrings (even if they have leading whitespace), and the code will
1666 or docstrings (even if they have leading whitespace), and the code will
1656 execute correctly. You can then use '%history -tn' to see the translated
1667 execute correctly. You can then use '%history -tn' to see the translated
1657 history without line numbers; this will give you the input after removal
1668 history without line numbers; this will give you the input after removal
1658 of all the leading prompts and whitespace, which can be pasted back into
1669 of all the leading prompts and whitespace, which can be pasted back into
1659 an editor.
1670 an editor.
1660
1671
1661 With these features, you can switch into this mode easily whenever you
1672 With these features, you can switch into this mode easily whenever you
1662 need to do testing and changes to doctests, without having to leave your
1673 need to do testing and changes to doctests, without having to leave your
1663 existing IPython session.
1674 existing IPython session.
1664
1675
1665
1676
1666 %ed: Alias to %edit.
1677 %ed: Alias to %edit.
1667
1678
1668
1679
1669 %edit: Bring up an editor and execute the resulting code.
1680 %edit: Bring up an editor and execute the resulting code.
1670
1681
1671 Usage: %edit [options] [args]
1682 Usage: %edit [options] [args]
1672
1683
1673 %edit runs IPython's editor hook. The default version of this hook is
1684 %edit runs IPython's editor hook. The default version of this hook is
1674 set to call the __IPYTHON__.rc.editor command. This is read from your
1685 set to call the __IPYTHON__.rc.editor command. This is read from your
1675 environment variable $EDITOR. If this isn't found, it will default to vi
1686 environment variable $EDITOR. If this isn't found, it will default to vi
1676 under Linux/Unix and to notepad under Windows. See the end of this
1687 under Linux/Unix and to notepad under Windows. See the end of this
1677 docstring for how to change the editor hook.
1688 docstring for how to change the editor hook.
1678
1689
1679 You can also set the value of this editor via the command line option
1690 You can also set the value of this editor via the command line option
1680 '-editor' or in your ipythonrc file. This is useful if you wish to use
1691 '-editor' or in your ipythonrc file. This is useful if you wish to use
1681 specifically for IPython an editor different from your typical default
1692 specifically for IPython an editor different from your typical default
1682 (and for Windows users who typically don't set environment variables).
1693 (and for Windows users who typically don't set environment variables).
1683
1694
1684 This command allows you to conveniently edit multi-line code right in
1695 This command allows you to conveniently edit multi-line code right in
1685 your IPython session.
1696 your IPython session.
1686
1697
1687 If called without arguments, %edit opens up an empty editor with a
1698 If called without arguments, %edit opens up an empty editor with a
1688 temporary file and will execute the contents of this file when you close
1699 temporary file and will execute the contents of this file when you close
1689 it (don't forget to save it!).
1700 it (don't forget to save it!).
1690
1701
1691 Options:
1702 Options:
1692
1703
1693 -n <number>: open the editor at a specified line number. By default, the
1704 -n <number>: open the editor at a specified line number. By default, the
1694 IPython editor hook uses the unix syntax 'editor +N filename', but you
1705 IPython editor hook uses the unix syntax 'editor +N filename', but you
1695 can configure this by providing your own modified hook if your favorite
1706 can configure this by providing your own modified hook if your favorite
1696 editor supports line-number specifications with a different syntax.
1707 editor supports line-number specifications with a different syntax.
1697
1708
1698 -p: this will call the editor with the same data as the previous time it
1709 -p: this will call the editor with the same data as the previous time it
1699 was used, regardless of how long ago (in your current session) it was.
1710 was used, regardless of how long ago (in your current session) it was.
1700
1711
1701 -r: use 'raw' input. This option only applies to input taken from the
1712 -r: use 'raw' input. This option only applies to input taken from the
1702 user's history. By default, the 'processed' history is used, so that
1713 user's history. By default, the 'processed' history is used, so that
1703 magics are loaded in their transformed version to valid Python. If this
1714 magics are loaded in their transformed version to valid Python. If this
1704 option is given, the raw input as typed as the command line is used
1715 option is given, the raw input as typed as the command line is used
1705 instead. When you exit the editor, it will be executed by IPython's own
1716 instead. When you exit the editor, it will be executed by IPython's own
1706 processor.
1717 processor.
1707
1718
1708 -x: do not execute the edited code immediately upon exit. This is mainly
1719 -x: do not execute the edited code immediately upon exit. This is mainly
1709 useful if you are editing programs which need to be called with command
1720 useful if you are editing programs which need to be called with command
1710 line arguments, which you can then do using %run.
1721 line arguments, which you can then do using %run.
1711
1722
1712 Arguments:
1723 Arguments:
1713
1724
1714 If arguments are given, the following possibilites exist:
1725 If arguments are given, the following possibilites exist:
1715
1726
1716 - The arguments are numbers or pairs of dash-separated numbers (like 1
1727 - The arguments are numbers or pairs of dash-separated numbers (like 1
1717 4-8 9). These are interpreted as lines of previous input to be loaded
1728 4-8 9). These are interpreted as lines of previous input to be loaded
1718 into the editor. The syntax is the same of the %macro command.
1729 into the editor. The syntax is the same of the %macro command.
1719
1730
1720 - If the argument doesn't start with a number, it is evaluated as a
1731 - If the argument doesn't start with a number, it is evaluated as a
1721 variable and its contents loaded into the editor. You can thus edit any
1732 variable and its contents loaded into the editor. You can thus edit any
1722 string which contains python code (including the result of previous edits).
1733 string which contains python code (including the result of previous edits).
1723
1734
1724 - If the argument is the name of an object (other than a string),
1735 - If the argument is the name of an object (other than a string),
1725 IPython will try to locate the file where it was defined and open the
1736 IPython will try to locate the file where it was defined and open the
1726 editor at the point where it is defined. You can use '%edit function' to
1737 editor at the point where it is defined. You can use '%edit function' to
1727 load an editor exactly at the point where 'function' is defined, edit it
1738 load an editor exactly at the point where 'function' is defined, edit it
1728 and have the file be executed automatically.
1739 and have the file be executed automatically.
1729
1740
1730 If the object is a macro (see %macro for details), this opens up your
1741 If the object is a macro (see %macro for details), this opens up your
1731 specified editor with a temporary file containing the macro's data. Upon
1742 specified editor with a temporary file containing the macro's data. Upon
1732 exit, the macro is reloaded with the contents of the file.
1743 exit, the macro is reloaded with the contents of the file.
1733
1744
1734 Note: opening at an exact line is only supported under Unix, and some
1745 Note: opening at an exact line is only supported under Unix, and some
1735 editors (like kedit and gedit up to Gnome 2.8) do not understand the
1746 editors (like kedit and gedit up to Gnome 2.8) do not understand the
1736 '+NUMBER' parameter necessary for this feature. Good editors like
1747 '+NUMBER' parameter necessary for this feature. Good editors like
1737 (X)Emacs, vi, jed, pico and joe all do.
1748 (X)Emacs, vi, jed, pico and joe all do.
1738
1749
1739 If the argument is not found as a variable, IPython will look for a
1750 If the argument is not found as a variable, IPython will look for a
1740 file with that name (adding .py if necessary) and load it into the
1751 file with that name (adding .py if necessary) and load it into the
1741 editor. It will execute its contents with execfile() when you exit,
1752 editor. It will execute its contents with execfile() when you exit,
1742 loading any code in the file into your interactive namespace.
1753 loading any code in the file into your interactive namespace.
1743
1754
1744 After executing your code, %edit will return as output the code you
1755 After executing your code, %edit will return as output the code you
1745 typed in the editor (except when it was an existing file). This way you
1756 typed in the editor (except when it was an existing file). This way you
1746 can reload the code in further invocations of %edit as a variable, via
1757 can reload the code in further invocations of %edit as a variable, via
1747 _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of the
1758 _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of the
1748 output.
1759 output.
1749
1760
1750 Note that %edit is also available through the alias %ed.
1761 Note that %edit is also available through the alias %ed.
1751
1762
1752 This is an example of creating a simple function inside the editor and
1763 This is an example of creating a simple function inside the editor and
1753 then modifying it. First, start up the editor::
1764 then modifying it. First, start up the editor::
1754
1765
1755 In [1]: ed
1766 In [1]: ed
1756 Editing... done. Executing edited code...
1767 Editing... done. Executing edited code...
1757 Out[1]: 'def foo():\n print "foo() was defined in an editing session"\n'
1768 Out[1]: 'def foo():\n print "foo() was defined in an editing session"\n'
1758
1769
1759 We can then call the function foo():
1770 We can then call the function foo():
1760
1771
1761 In [2]: foo()
1772 In [2]: foo()
1762 foo() was defined in an editing session
1773 foo() was defined in an editing session
1763
1774
1764 Now we edit foo. IPython automatically loads the editor with the
1775 Now we edit foo. IPython automatically loads the editor with the
1765 (temporary) file where foo() was previously defined:
1776 (temporary) file where foo() was previously defined:
1766
1777
1767 In [3]: ed foo
1778 In [3]: ed foo
1768 Editing... done. Executing edited code...
1779 Editing... done. Executing edited code...
1769
1780
1770 And if we call foo() again we get the modified version:
1781 And if we call foo() again we get the modified version:
1771
1782
1772 In [4]: foo()
1783 In [4]: foo()
1773 foo() has now been changed!
1784 foo() has now been changed!
1774
1785
1775 Here is an example of how to edit a code snippet successive times. First
1786 Here is an example of how to edit a code snippet successive times. First
1776 we call the editor:
1787 we call the editor:
1777
1788
1778 In [8]: ed
1789 In [8]: ed
1779 Editing... done. Executing edited code...
1790 Editing... done. Executing edited code...
1780 hello
1791 hello
1781 Out[8]: "print 'hello'\n"
1792 Out[8]: "print 'hello'\n"
1782
1793
1783 Now we call it again with the previous output (stored in _):
1794 Now we call it again with the previous output (stored in _):
1784
1795
1785 In [9]: ed _
1796 In [9]: ed _
1786 Editing... done. Executing edited code...
1797 Editing... done. Executing edited code...
1787 hello world
1798 hello world
1788 Out[9]: "print 'hello world'\n"
1799 Out[9]: "print 'hello world'\n"
1789
1800
1790 Now we call it with the output #8 (stored in _8, also as Out[8]):
1801 Now we call it with the output #8 (stored in _8, also as Out[8]):
1791
1802
1792 In [10]: ed _8
1803 In [10]: ed _8
1793 Editing... done. Executing edited code...
1804 Editing... done. Executing edited code...
1794 hello again
1805 hello again
1795 Out[10]: "print 'hello again'\n"
1806 Out[10]: "print 'hello again'\n"
1796
1807
1797 Changing the default editor hook:
1808 Changing the default editor hook:
1798
1809
1799 If you wish to write your own editor hook, you can put it in a
1810 If you wish to write your own editor hook, you can put it in a
1800 configuration file which you load at startup time. The default hook is
1811 configuration file which you load at startup time. The default hook is
1801 defined in the IPython.hooks module, and you can use that as a starting
1812 defined in the IPython.hooks module, and you can use that as a starting
1802 example for further modifications. That file also has general
1813 example for further modifications. That file also has general
1803 instructions on how to set a new hook for use once you've defined it.
1814 instructions on how to set a new hook for use once you've defined it.
1804
1815
1805
1816
1806 %env: List environment variables.
1817 %env: List environment variables.
1807
1818
1808
1819
1809 %exit: Exit IPython, confirming if configured to do so.
1820 %exit: Exit IPython, confirming if configured to do so.
1810
1821
1811 You can configure whether IPython asks for confirmation upon exit by
1822 You can configure whether IPython asks for confirmation upon exit by
1812 setting the confirm_exit flag in the ipythonrc file.
1823 setting the confirm_exit flag in the ipythonrc file.
1813
1824
1814
1825
1815 %logoff: Temporarily stop logging.
1826 %logoff: Temporarily stop logging.
1816
1827
1817 You must have previously started logging.
1828 You must have previously started logging.
1818
1829
1819
1830
1820 %logon: Restart logging.
1831 %logon: Restart logging.
1821
1832
1822 This function is for restarting logging which you've temporarily stopped
1833 This function is for restarting logging which you've temporarily stopped
1823 with %logoff. For starting logging for the first time, you must use the
1834 with %logoff. For starting logging for the first time, you must use the
1824 %logstart function, which allows you to specify an optional log filename.
1835 %logstart function, which allows you to specify an optional log filename.
1825
1836
1826
1837
1827 %logstart: Start logging anywhere in a session.
1838 %logstart: Start logging anywhere in a session.
1828
1839
1829 %logstart [-o|-r|-t] [log_name [log_mode]]
1840 %logstart [-o|-r|-t] [log_name [log_mode]]
1830
1841
1831 If no name is given, it defaults to a file named 'ipython_log.py' in
1842 If no name is given, it defaults to a file named 'ipython_log.py' in
1832 your current directory, in 'rotate' mode (see below).
1843 your current directory, in 'rotate' mode (see below).
1833
1844
1834 '%logstart name' saves to file 'name' in 'backup' mode. It saves your
1845 '%logstart name' saves to file 'name' in 'backup' mode. It saves your
1835 history up to that point and then continues logging.
1846 history up to that point and then continues logging.
1836
1847
1837 %logstart takes a second optional parameter: logging mode. This can be
1848 %logstart takes a second optional parameter: logging mode. This can be
1838 one of (note that the modes are given unquoted):
1849 one of (note that the modes are given unquoted):
1839 append: well, that says it.
1850 append: well, that says it.
1840 backup: rename (if exists) to name and start name.
1851 backup: rename (if exists) to name and start name.
1841 global: single logfile in your home dir, appended to.
1852 global: single logfile in your home dir, appended to.
1842 over : overwrite existing log.
1853 over : overwrite existing log.
1843 rotate: create rotating logs name.1 , name.2 , etc.
1854 rotate: create rotating logs name.1 , name.2 , etc.
1844
1855
1845 Options:
1856 Options:
1846
1857
1847 -o: log also IPython's output. In this mode, all commands which generate
1858 -o: log also IPython's output. In this mode, all commands which generate
1848 an Out[NN] prompt are recorded to the logfile, right after their
1859 an Out[NN] prompt are recorded to the logfile, right after their
1849 corresponding input line. The output lines are always prepended with a
1860 corresponding input line. The output lines are always prepended with a
1850 '#[Out]# ' marker, so that the log remains valid Python code.
1861 '#[Out]# ' marker, so that the log remains valid Python code.
1851
1862
1852 Since this marker is always the same, filtering only the output from a
1863 Since this marker is always the same, filtering only the output from a
1853 log is very easy, using for example a simple awk call:
1864 log is very easy, using for example a simple awk call:
1854
1865
1855 awk -F'#
1866 awk -F'#
1856
1867
1857 \begin{displaymath}Out\end{displaymath}
1868 \begin{displaymath}Out\end{displaymath}
1858
1869
1859 # ' 'if($2) print $2' ipython_log.py
1870 # ' 'if($2) print $2' ipython_log.py
1860
1871
1861 -r: log 'raw' input. Normally, IPython's logs contain the processed
1872 -r: log 'raw' input. Normally, IPython's logs contain the processed
1862 input, so that user lines are logged in their final form, converted into
1873 input, so that user lines are logged in their final form, converted into
1863 valid Python. For example, %Exit is logged as '_ip.magic("Exit"). If the
1874 valid Python. For example, %Exit is logged as '_ip.magic("Exit"). If the
1864 -r flag is given, all input is logged exactly as typed, with no
1875 -r flag is given, all input is logged exactly as typed, with no
1865 transformations applied.
1876 transformations applied.
1866
1877
1867 -t: put timestamps before each input line logged (these are put in
1878 -t: put timestamps before each input line logged (these are put in
1868 comments).
1879 comments).
1869
1880
1870
1881
1871 %logstate: Print the status of the logging system.
1882 %logstate: Print the status of the logging system.
1872
1883
1873
1884
1874 %logstop: Fully stop logging and close log file.
1885 %logstop: Fully stop logging and close log file.
1875
1886
1876 In order to start logging again, a new %logstart call needs to be made,
1887 In order to start logging again, a new %logstart call needs to be made,
1877 possibly (though not necessarily) with a new filename, mode and other
1888 possibly (though not necessarily) with a new filename, mode and other
1878 options.
1889 options.
1879
1890
1880
1891
1881 %lsmagic: List currently available magic functions.
1892 %lsmagic: List currently available magic functions.
1882
1893
1883
1894
1884 %macro: Define a set of input lines as a macro for future re-execution.
1895 %macro: Define a set of input lines as a macro for future re-execution.
1885
1896
1886 Usage:
1897 Usage:
1887 %macro [options] name n1-n2 n3-n4 ... n5 .. n6 ...
1898 %macro [options] name n1-n2 n3-n4 ... n5 .. n6 ...
1888
1899
1889 Options:
1900 Options:
1890
1901
1891 -r: use 'raw' input. By default, the 'processed' history is used, so
1902 -r: use 'raw' input. By default, the 'processed' history is used, so
1892 that magics are loaded in their transformed version to valid Python. If
1903 that magics are loaded in their transformed version to valid Python. If
1893 this option is given, the raw input as typed as the command line is used
1904 this option is given, the raw input as typed as the command line is used
1894 instead.
1905 instead.
1895
1906
1896 This will define a global variable called 'name' which is a string made
1907 This will define a global variable called 'name' which is a string made
1897 of joining the slices and lines you specify (n1,n2,... numbers above)
1908 of joining the slices and lines you specify (n1,n2,... numbers above)
1898 from your input history into a single string. This variable acts like an
1909 from your input history into a single string. This variable acts like an
1899 automatic function which re-executes those lines as if you had typed
1910 automatic function which re-executes those lines as if you had typed
1900 them. You just type 'name' at the prompt and the code executes.
1911 them. You just type 'name' at the prompt and the code executes.
1901
1912
1902 The notation for indicating number ranges is: n1-n2 means 'use line
1913 The notation for indicating number ranges is: n1-n2 means 'use line
1903 numbers n1,...n2' (the endpoint is included). That is, '5-7' means using
1914 numbers n1,...n2' (the endpoint is included). That is, '5-7' means using
1904 the lines numbered 5,6 and 7.
1915 the lines numbered 5,6 and 7.
1905
1916
1906 Note: as a 'hidden' feature, you can also use traditional python slice
1917 Note: as a 'hidden' feature, you can also use traditional python slice
1907 notation, where N:M means numbers N through M-1.
1918 notation, where N:M means numbers N through M-1.
1908
1919
1909 For example, if your history contains (%hist prints it):
1920 For example, if your history contains (%hist prints it):
1910
1921
1911 44: x=1
1922 44: x=1
1912 45: y=3
1923 45: y=3
1913 46: z=x+y
1924 46: z=x+y
1914 47: print x
1925 47: print x
1915 48: a=5
1926 48: a=5
1916 49: print 'x',x,'y',y
1927 49: print 'x',x,'y',y
1917
1928
1918 you can create a macro with lines 44 through 47 (included) and line 49
1929 you can create a macro with lines 44 through 47 (included) and line 49
1919 called my_macro with:
1930 called my_macro with:
1920
1931
1921 In [51]: %macro my_macro 44-47 49
1932 In [51]: %macro my_macro 44-47 49
1922
1933
1923 Now, typing 'my_macro' (without quotes) will re-execute all this code in
1934 Now, typing 'my_macro' (without quotes) will re-execute all this code in
1924 one pass.
1935 one pass.
1925
1936
1926 You don't need to give the line-numbers in order, and any given line
1937 You don't need to give the line-numbers in order, and any given line
1927 number can appear multiple times. You can assemble macros with any lines
1938 number can appear multiple times. You can assemble macros with any lines
1928 from your input history in any order.
1939 from your input history in any order.
1929
1940
1930 The macro is a simple object which holds its value in an attribute, but
1941 The macro is a simple object which holds its value in an attribute, but
1931 IPython's display system checks for macros and executes them as code
1942 IPython's display system checks for macros and executes them as code
1932 instead of printing them when you type their name.
1943 instead of printing them when you type their name.
1933
1944
1934 You can view a macro's contents by explicitly printing it with:
1945 You can view a macro's contents by explicitly printing it with:
1935
1946
1936 'print macro_name'.
1947 'print macro_name'.
1937
1948
1938 For one-off cases which DON'T contain magic function calls in them you
1949 For one-off cases which DON'T contain magic function calls in them you
1939 can obtain similar results by explicitly executing slices from your
1950 can obtain similar results by explicitly executing slices from your
1940 input history with:
1951 input history with:
1941
1952
1942 In [60]: exec In[44:48]+In[49]
1953 In [60]: exec In[44:48]+In[49]
1943
1954
1944
1955
1945 %magic: Print information about the magic function system.
1956 %magic: Print information about the magic function system.
1946
1957
1947
1958
1948 %page: Pretty print the object and display it through a pager.
1959 %page: Pretty print the object and display it through a pager.
1949
1960
1950 %page [options] OBJECT
1961 %page [options] OBJECT
1951
1962
1952 If no object is given, use _ (last output).
1963 If no object is given, use _ (last output).
1953
1964
1954 Options:
1965 Options:
1955
1966
1956 -r: page str(object), don't pretty-print it.
1967 -r: page str(object), don't pretty-print it.
1957
1968
1958
1969
1959 %pdb: Control the automatic calling of the pdb interactive debugger.
1970 %pdb: Control the automatic calling of the pdb interactive debugger.
1960
1971
1961 Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without
1972 Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without
1962 argument it works as a toggle.
1973 argument it works as a toggle.
1963
1974
1964 When an exception is triggered, IPython can optionally call the
1975 When an exception is triggered, IPython can optionally call the
1965 interactive pdb debugger after the traceback printout. %pdb toggles this
1976 interactive pdb debugger after the traceback printout. %pdb toggles this
1966 feature on and off.
1977 feature on and off.
1967
1978
1968 The initial state of this feature is set in your ipythonrc configuration
1979 The initial state of this feature is set in your ipythonrc configuration
1969 file (the variable is called 'pdb').
1980 file (the variable is called 'pdb').
1970
1981
1971 If you want to just activate the debugger AFTER an exception has fired,
1982 If you want to just activate the debugger AFTER an exception has fired,
1972 without having to type '%pdb on' and rerunning your code, you can use
1983 without having to type '%pdb on' and rerunning your code, you can use
1973 the %debug magic.
1984 the %debug magic.
1974
1985
1975
1986
1976 %pdef: Print the definition header for any callable object.
1987 %pdef: Print the definition header for any callable object.
1977
1988
1978 If the object is a class, print the constructor information.
1989 If the object is a class, print the constructor information.
1979
1990
1980
1991
1981 %pdoc: Print the docstring for an object.
1992 %pdoc: Print the docstring for an object.
1982
1993
1983 If the given object is a class, it will print both the class and the
1994 If the given object is a class, it will print both the class and the
1984 constructor docstrings.
1995 constructor docstrings.
1985
1996
1986
1997
1987 %pfile: Print (or run through pager) the file where an object is defined.
1998 %pfile: Print (or run through pager) the file where an object is defined.
1988
1999
1989 The file opens at the line where the object definition begins. IPython
2000 The file opens at the line where the object definition begins. IPython
1990 will honor the environment variable PAGER if set, and otherwise will do
2001 will honor the environment variable PAGER if set, and otherwise will do
1991 its best to print the file in a convenient form.
2002 its best to print the file in a convenient form.
1992
2003
1993 If the given argument is not an object currently defined, IPython will
2004 If the given argument is not an object currently defined, IPython will
1994 try to interpret it as a filename (automatically adding a .py extension
2005 try to interpret it as a filename (automatically adding a .py extension
1995 if needed). You can thus use %pfile as a syntax highlighting code viewer.
2006 if needed). You can thus use %pfile as a syntax highlighting code viewer.
1996
2007
1997
2008
1998 %pinfo: Provide detailed information about an object.
2009 %pinfo: Provide detailed information about an object.
1999
2010
2000 '%pinfo object' is just a synonym for object? or ?object.
2011 '%pinfo object' is just a synonym for object? or ?object.
2001
2012
2002
2013
2003 %popd: Change to directory popped off the top of the stack.
2014 %popd: Change to directory popped off the top of the stack.
2004
2015
2005
2016
2006 %profile: Print your currently active IPyhton profile.
2017 %profile: Print your currently active IPyhton profile.
2007
2018
2008
2019
2009 %prun: Run a statement through the python code profiler.
2020 %prun: Run a statement through the python code profiler.
2010
2021
2011 Usage:
2022 Usage:
2012 %prun [options] statement
2023 %prun [options] statement
2013
2024
2014 The given statement (which doesn't require quote marks) is run via the
2025 The given statement (which doesn't require quote marks) is run via the
2015 python profiler in a manner similar to the profile.run() function.
2026 python profiler in a manner similar to the profile.run() function.
2016 Namespaces are internally managed to work correctly; profile.run cannot
2027 Namespaces are internally managed to work correctly; profile.run cannot
2017 be used in IPython because it makes certain assumptions about namespaces
2028 be used in IPython because it makes certain assumptions about namespaces
2018 which do not hold under IPython.
2029 which do not hold under IPython.
2019
2030
2020 Options:
2031 Options:
2021
2032
2022 -l <limit>: you can place restrictions on what or how much of the
2033 -l <limit>: you can place restrictions on what or how much of the
2023 profile gets printed. The limit value can be:
2034 profile gets printed. The limit value can be:
2024
2035
2025 * A string: only information for function names containing this string
2036 * A string: only information for function names containing this string
2026 is printed.
2037 is printed.
2027
2038
2028 * An integer: only these many lines are printed.
2039 * An integer: only these many lines are printed.
2029
2040
2030 * A float (between 0 and 1): this fraction of the report is printed (for
2041 * A float (between 0 and 1): this fraction of the report is printed (for
2031 example, use a limit of 0.4 to see the topmost 40% only).
2042 example, use a limit of 0.4 to see the topmost 40% only).
2032
2043
2033 You can combine several limits with repeated use of the option. For
2044 You can combine several limits with repeated use of the option. For
2034 example, '-l __init__ -l 5' will print only the topmost 5 lines of
2045 example, '-l __init__ -l 5' will print only the topmost 5 lines of
2035 information about class constructors.
2046 information about class constructors.
2036
2047
2037 -r: return the pstats.Stats object generated by the profiling. This
2048 -r: return the pstats.Stats object generated by the profiling. This
2038 object has all the information about the profile in it, and you can
2049 object has all the information about the profile in it, and you can
2039 later use it for further analysis or in other functions.
2050 later use it for further analysis or in other functions.
2040
2051
2041 -s <key>: sort profile by given key. You can provide more than one key
2052 -s <key>: sort profile by given key. You can provide more than one key
2042 by using the option several times: '-s key1 -s key2 -s key3...'. The
2053 by using the option several times: '-s key1 -s key2 -s key3...'. The
2043 default sorting key is 'time'.
2054 default sorting key is 'time'.
2044
2055
2045 The following is copied verbatim from the profile documentation
2056 The following is copied verbatim from the profile documentation
2046 referenced below:
2057 referenced below:
2047
2058
2048 When more than one key is provided, additional keys are used as
2059 When more than one key is provided, additional keys are used as
2049 secondary criteria when the there is equality in all keys selected
2060 secondary criteria when the there is equality in all keys selected
2050 before them.
2061 before them.
2051
2062
2052 Abbreviations can be used for any key names, as long as the abbreviation
2063 Abbreviations can be used for any key names, as long as the abbreviation
2053 is unambiguous. The following are the keys currently defined:
2064 is unambiguous. The following are the keys currently defined:
2054
2065
2055 Valid Arg Meaning
2066 Valid Arg Meaning
2056 "calls" call count
2067 "calls" call count
2057 "cumulative" cumulative time
2068 "cumulative" cumulative time
2058 "file" file name
2069 "file" file name
2059 "module" file name
2070 "module" file name
2060 "pcalls" primitive call count
2071 "pcalls" primitive call count
2061 "line" line number
2072 "line" line number
2062 "name" function name
2073 "name" function name
2063 "nfl" name/file/line
2074 "nfl" name/file/line
2064 "stdname" standard name
2075 "stdname" standard name
2065 "time" internal time
2076 "time" internal time
2066
2077
2067 Note that all sorts on statistics are in descending order (placing most
2078 Note that all sorts on statistics are in descending order (placing most
2068 time consuming items first), where as name, file, and line number
2079 time consuming items first), where as name, file, and line number
2069 searches are in ascending order (i.e., alphabetical). The subtle
2080 searches are in ascending order (i.e., alphabetical). The subtle
2070 distinction between "nfl" and "stdname" is that the standard name is a
2081 distinction between "nfl" and "stdname" is that the standard name is a
2071 sort of the name as printed, which means that the embedded line numbers
2082 sort of the name as printed, which means that the embedded line numbers
2072 get compared in an odd way. For example, lines 3, 20, and 40 would (if
2083 get compared in an odd way. For example, lines 3, 20, and 40 would (if
2073 the file names were the same) appear in the string order "20" "3" and
2084 the file names were the same) appear in the string order "20" "3" and
2074 "40". In contrast, "nfl" does a numeric compare of the line numbers. In
2085 "40". In contrast, "nfl" does a numeric compare of the line numbers. In
2075 fact, sort_stats("nfl") is the same as sort_stats("name", "file", "line").
2086 fact, sort_stats("nfl") is the same as sort_stats("name", "file", "line").
2076
2087
2077 -T <filename>: save profile results as shown on screen to a text file.
2088 -T <filename>: save profile results as shown on screen to a text file.
2078 The profile is still shown on screen.
2089 The profile is still shown on screen.
2079
2090
2080 -D <filename>: save (via dump_stats) profile statistics to given
2091 -D <filename>: save (via dump_stats) profile statistics to given
2081 filename. This data is in a format understod by the pstats module, and
2092 filename. This data is in a format understod by the pstats module, and
2082 is generated by a call to the dump_stats() method of profile objects.
2093 is generated by a call to the dump_stats() method of profile objects.
2083 The profile is still shown on screen.
2094 The profile is still shown on screen.
2084
2095
2085 If you want to run complete programs under the profiler's control, use
2096 If you want to run complete programs under the profiler's control, use
2086 '%run -p [prof_opts] filename.py [args to program]' where prof_opts
2097 '%run -p [prof_opts] filename.py [args to program]' where prof_opts
2087 contains profiler specific options as described here.
2098 contains profiler specific options as described here.
2088
2099
2089 You can read the complete documentation for the profile module with:
2100 You can read the complete documentation for the profile module with:
2090 In [1]: import profile; profile.help()
2101 In [1]: import profile; profile.help()
2091
2102
2092
2103
2093 %psearch: Search for object in namespaces by wildcard.
2104 %psearch: Search for object in namespaces by wildcard.
2094
2105
2095 %psearch [options] PATTERN [OBJECT TYPE]
2106 %psearch [options] PATTERN [OBJECT TYPE]
2096
2107
2097 Note: ? can be used as a synonym for %psearch, at the beginning or at
2108 Note: ? can be used as a synonym for %psearch, at the beginning or at
2098 the end: both a*? and ?a* are equivalent to '%psearch a*'. Still, the
2109 the end: both a*? and ?a* are equivalent to '%psearch a*'. Still, the
2099 rest of the command line must be unchanged (options come first), so for
2110 rest of the command line must be unchanged (options come first), so for
2100 example the following forms are equivalent
2111 example the following forms are equivalent
2101
2112
2102 %psearch -i a* function -i a* function? ?-i a* function
2113 %psearch -i a* function -i a* function? ?-i a* function
2103
2114
2104 Arguments:
2115 Arguments:
2105
2116
2106 PATTERN
2117 PATTERN
2107
2118
2108 where PATTERN is a string containing * as a wildcard similar to its use
2119 where PATTERN is a string containing * as a wildcard similar to its use
2109 in a shell. The pattern is matched in all namespaces on the search path.
2120 in a shell. The pattern is matched in all namespaces on the search path.
2110 By default objects starting with a single _ are not matched, many
2121 By default objects starting with a single _ are not matched, many
2111 IPython generated objects have a single underscore. The default is case
2122 IPython generated objects have a single underscore. The default is case
2112 insensitive matching. Matching is also done on the attributes of objects
2123 insensitive matching. Matching is also done on the attributes of objects
2113 and not only on the objects in a module.
2124 and not only on the objects in a module.
2114
2125
2115 [OBJECT TYPE]
2126 [OBJECT TYPE]
2116
2127
2117 Is the name of a python type from the types module. The name is given in
2128 Is the name of a python type from the types module. The name is given in
2118 lowercase without the ending type, ex. StringType is written string. By
2129 lowercase without the ending type, ex. StringType is written string. By
2119 adding a type here only objects matching the given type are matched.
2130 adding a type here only objects matching the given type are matched.
2120 Using all here makes the pattern match all types (this is the default).
2131 Using all here makes the pattern match all types (this is the default).
2121
2132
2122 Options:
2133 Options:
2123
2134
2124 -a: makes the pattern match even objects whose names start with a single
2135 -a: makes the pattern match even objects whose names start with a single
2125 underscore. These names are normally ommitted from the search.
2136 underscore. These names are normally ommitted from the search.
2126
2137
2127 -i/-c: make the pattern case insensitive/sensitive. If neither of these
2138 -i/-c: make the pattern case insensitive/sensitive. If neither of these
2128 options is given, the default is read from your ipythonrc file. The
2139 options is given, the default is read from your ipythonrc file. The
2129 option name which sets this value is 'wildcards_case_sensitive'. If this
2140 option name which sets this value is 'wildcards_case_sensitive'. If this
2130 option is not specified in your ipythonrc file, IPython's internal
2141 option is not specified in your ipythonrc file, IPython's internal
2131 default is to do a case sensitive search.
2142 default is to do a case sensitive search.
2132
2143
2133 -e/-s NAMESPACE: exclude/search a given namespace. The pattern you
2144 -e/-s NAMESPACE: exclude/search a given namespace. The pattern you
2134 specifiy can be searched in any of the following namespaces: 'builtin',
2145 specifiy can be searched in any of the following namespaces: 'builtin',
2135 'user', 'user_global','internal', 'alias', where 'builtin' and 'user'
2146 'user', 'user_global','internal', 'alias', where 'builtin' and 'user'
2136 are the search defaults. Note that you should not use quotes when
2147 are the search defaults. Note that you should not use quotes when
2137 specifying namespaces.
2148 specifying namespaces.
2138
2149
2139 'Builtin' contains the python module builtin, 'user' contains all user
2150 'Builtin' contains the python module builtin, 'user' contains all user
2140 data, 'alias' only contain the shell aliases and no python objects,
2151 data, 'alias' only contain the shell aliases and no python objects,
2141 'internal' contains objects used by IPython. The 'user_global' namespace
2152 'internal' contains objects used by IPython. The 'user_global' namespace
2142 is only used by embedded IPython instances, and it contains module-level
2153 is only used by embedded IPython instances, and it contains module-level
2143 globals. You can add namespaces to the search with -s or exclude them
2154 globals. You can add namespaces to the search with -s or exclude them
2144 with -e (these options can be given more than once).
2155 with -e (these options can be given more than once).
2145
2156
2146 Examples:
2157 Examples:
2147
2158
2148 %psearch a* -> objects beginning with an a %psearch -e builtin a* ->
2159 %psearch a* -> objects beginning with an a %psearch -e builtin a* ->
2149 objects NOT in the builtin space starting in a %psearch a* function ->
2160 objects NOT in the builtin space starting in a %psearch a* function ->
2150 all functions beginning with an a %psearch re.e* -> objects beginning
2161 all functions beginning with an a %psearch re.e* -> objects beginning
2151 with an e in module re %psearch r*.e* -> objects that start with e in
2162 with an e in module re %psearch r*.e* -> objects that start with e in
2152 modules starting in r %psearch r*.* string -> all strings in modules
2163 modules starting in r %psearch r*.* string -> all strings in modules
2153 beginning with r
2164 beginning with r
2154
2165
2155 Case sensitve search:
2166 Case sensitve search:
2156
2167
2157 %psearch -c a* list all object beginning with lower case a
2168 %psearch -c a* list all object beginning with lower case a
2158
2169
2159 Show objects beginning with a single _:
2170 Show objects beginning with a single _:
2160
2171
2161 %psearch -a _* list objects beginning with a single underscore
2172 %psearch -a _* list objects beginning with a single underscore
2162
2173
2163
2174
2164 %psource: Print (or run through pager) the source code for an object.
2175 %psource: Print (or run through pager) the source code for an object.
2165
2176
2166
2177
2167 %pushd: Place the current dir on stack and change directory.
2178 %pushd: Place the current dir on stack and change directory.
2168
2179
2169 Usage:
2180 Usage:
2170 %pushd ['dirname']
2181 %pushd ['dirname']
2171
2182
2172
2183
2173 %pwd: Return the current working directory path.
2184 %pwd: Return the current working directory path.
2174
2185
2175
2186
2176 %pycat: Show a syntax-highlighted file through a pager.
2187 %pycat: Show a syntax-highlighted file through a pager.
2177
2188
2178 This magic is similar to the cat utility, but it will assume the file to
2189 This magic is similar to the cat utility, but it will assume the file to
2179 be Python source and will show it with syntax highlighting.
2190 be Python source and will show it with syntax highlighting.
2180
2191
2181
2192
2182 %quickref: Show a quick reference sheet
2193 %quickref: Show a quick reference sheet
2183
2194
2184
2195
2185 %quit: Exit IPython, confirming if configured to do so (like %exit)
2196 %quit: Exit IPython, confirming if configured to do so (like %exit)
2186
2197
2187
2198
2188 %r: Repeat previous input.
2199 %r: Repeat previous input.
2189
2200
2190 Note: Consider using the more powerfull %rep instead!
2201 Note: Consider using the more powerfull %rep instead!
2191
2202
2192 If given an argument, repeats the previous command which starts with the
2203 If given an argument, repeats the previous command which starts with the
2193 same string, otherwise it just repeats the previous input.
2204 same string, otherwise it just repeats the previous input.
2194
2205
2195 Shell escaped commands (with ! as first character) are not recognized by
2206 Shell escaped commands (with ! as first character) are not recognized by
2196 this system, only pure python code and magic commands.
2207 this system, only pure python code and magic commands.
2197
2208
2198
2209
2199 %rehashx: Update the alias table with all executable files in $PATH.
2210 %rehashx: Update the alias table with all executable files in $PATH.
2200
2211
2201 This version explicitly checks that every entry in $PATH is a file with
2212 This version explicitly checks that every entry in $PATH is a file with
2202 execute access (os.X_OK), so it is much slower than %rehash.
2213 execute access (os.X_OK), so it is much slower than %rehash.
2203
2214
2204 Under Windows, it checks executability as a match agains a ``|``-separated
2215 Under Windows, it checks executability as a match agains a ``|``-separated
2205 string of extensions, stored in the IPython config variable
2216 string of extensions, stored in the IPython config variable
2206 win_exec_ext. This defaults to ``exe|com|bat``.
2217 win_exec_ext. This defaults to ``exe|com|bat``.
2207
2218
2208 This function also resets the root module cache of module completer,
2219 This function also resets the root module cache of module completer,
2209 used on slow filesystems.
2220 used on slow filesystems.
2210
2221
2211
2222
2212 %reset: Resets the namespace by removing all names defined by the user.
2223 %reset: Resets the namespace by removing all names defined by the user.
2213
2224
2214 Input/Output history are left around in case you need them.
2225 Input/Output history are left around in case you need them.
2215
2226
2216
2227
2217 %run: Run the named file inside IPython as a program.
2228 %run: Run the named file inside IPython as a program.
2218
2229
2219 Usage:
2230 Usage:
2220 %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args]
2231 %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args]
2221
2232
2222 Parameters after the filename are passed as command-line arguments to
2233 Parameters after the filename are passed as command-line arguments to
2223 the program (put in sys.argv). Then, control returns to IPython's prompt.
2234 the program (put in sys.argv). Then, control returns to IPython's prompt.
2224
2235
2225 This is similar to running at a system prompt:
2236 This is similar to running at a system prompt:
2226 $ python file args
2237 $ python file args
2227 but with the advantage of giving you IPython's tracebacks, and of
2238 but with the advantage of giving you IPython's tracebacks, and of
2228 loading all variables into your interactive namespace for further use
2239 loading all variables into your interactive namespace for further use
2229 (unless -p is used, see below).
2240 (unless -p is used, see below).
2230
2241
2231 The file is executed in a namespace initially consisting only of
2242 The file is executed in a namespace initially consisting only of
2232 __name__=='__main__' and sys.argv constructed as indicated. It thus sees
2243 __name__=='__main__' and sys.argv constructed as indicated. It thus sees
2233 its environment as if it were being run as a stand-alone program (except
2244 its environment as if it were being run as a stand-alone program (except
2234 for sharing global objects such as previously imported modules). But
2245 for sharing global objects such as previously imported modules). But
2235 after execution, the IPython interactive namespace gets updated with all
2246 after execution, the IPython interactive namespace gets updated with all
2236 variables defined in the program (except for __name__ and sys.argv).
2247 variables defined in the program (except for __name__ and sys.argv).
2237 This allows for very convenient loading of code for interactive work,
2248 This allows for very convenient loading of code for interactive work,
2238 while giving each program a 'clean sheet' to run in.
2249 while giving each program a 'clean sheet' to run in.
2239
2250
2240 Options:
2251 Options:
2241
2252
2242 -n: __name__ is NOT set to '__main__', but to the running file's name
2253 -n: __name__ is NOT set to '__main__', but to the running file's name
2243 without extension (as python does under import). This allows running
2254 without extension (as python does under import). This allows running
2244 scripts and reloading the definitions in them without calling code
2255 scripts and reloading the definitions in them without calling code
2245 protected by an ' if __name__ == "__main__" ' clause.
2256 protected by an ' if __name__ == "__main__" ' clause.
2246
2257
2247 -i: run the file in IPython's namespace instead of an empty one. This is
2258 -i: run the file in IPython's namespace instead of an empty one. This is
2248 useful if you are experimenting with code written in a text editor which
2259 useful if you are experimenting with code written in a text editor which
2249 depends on variables defined interactively.
2260 depends on variables defined interactively.
2250
2261
2251 -e: ignore sys.exit() calls or SystemExit exceptions in the script being
2262 -e: ignore sys.exit() calls or SystemExit exceptions in the script being
2252 run. This is particularly useful if IPython is being used to run
2263 run. This is particularly useful if IPython is being used to run
2253 unittests, which always exit with a sys.exit() call. In such cases you
2264 unittests, which always exit with a sys.exit() call. In such cases you
2254 are interested in the output of the test results, not in seeing a
2265 are interested in the output of the test results, not in seeing a
2255 traceback of the unittest module.
2266 traceback of the unittest module.
2256
2267
2257 -t: print timing information at the end of the run. IPython will give
2268 -t: print timing information at the end of the run. IPython will give
2258 you an estimated CPU time consumption for your script, which under Unix
2269 you an estimated CPU time consumption for your script, which under Unix
2259 uses the resource module to avoid the wraparound problems of
2270 uses the resource module to avoid the wraparound problems of
2260 time.clock(). Under Unix, an estimate of time spent on system tasks is
2271 time.clock(). Under Unix, an estimate of time spent on system tasks is
2261 also given (for Windows platforms this is reported as 0.0).
2272 also given (for Windows platforms this is reported as 0.0).
2262
2273
2263 If -t is given, an additional -N<N> option can be given, where <N> must
2274 If -t is given, an additional -N<N> option can be given, where <N> must
2264 be an integer indicating how many times you want the script to run. The
2275 be an integer indicating how many times you want the script to run. The
2265 final timing report will include total and per run results.
2276 final timing report will include total and per run results.
2266
2277
2267 For example (testing the script uniq_stable.py):
2278 For example (testing the script uniq_stable.py):
2268
2279
2269 In [1]: run -t uniq_stable
2280 In [1]: run -t uniq_stable
2270
2281
2271 IPython CPU timings (estimated):
2282 IPython CPU timings (estimated):
2272 User : 0.19597 s.
2283 User : 0.19597 s.
2273 System: 0.0 s.
2284 System: 0.0 s.
2274
2285
2275 In [2]: run -t -N5 uniq_stable
2286 In [2]: run -t -N5 uniq_stable
2276
2287
2277 IPython CPU timings (estimated):
2288 IPython CPU timings (estimated):
2278 Total runs performed: 5
2289 Total runs performed: 5
2279 Times : Total Per run
2290 Times : Total Per run
2280 User : 0.910862 s, 0.1821724 s.
2291 User : 0.910862 s, 0.1821724 s.
2281 System: 0.0 s, 0.0 s.
2292 System: 0.0 s, 0.0 s.
2282
2293
2283 -d: run your program under the control of pdb, the Python debugger. This
2294 -d: run your program under the control of pdb, the Python debugger. This
2284 allows you to execute your program step by step, watch variables, etc.
2295 allows you to execute your program step by step, watch variables, etc.
2285 Internally, what IPython does is similar to calling:
2296 Internally, what IPython does is similar to calling:
2286
2297
2287 pdb.run('execfile("YOURFILENAME")')
2298 pdb.run('execfile("YOURFILENAME")')
2288
2299
2289 with a breakpoint set on line 1 of your file. You can change the line
2300 with a breakpoint set on line 1 of your file. You can change the line
2290 number for this automatic breakpoint to be <N> by using the -bN option
2301 number for this automatic breakpoint to be <N> by using the -bN option
2291 (where N must be an integer). For example:
2302 (where N must be an integer). For example:
2292
2303
2293 %run -d -b40 myscript
2304 %run -d -b40 myscript
2294
2305
2295 will set the first breakpoint at line 40 in myscript.py. Note that the
2306 will set the first breakpoint at line 40 in myscript.py. Note that the
2296 first breakpoint must be set on a line which actually does something
2307 first breakpoint must be set on a line which actually does something
2297 (not a comment or docstring) for it to stop execution.
2308 (not a comment or docstring) for it to stop execution.
2298
2309
2299 When the pdb debugger starts, you will see a (Pdb) prompt. You must
2310 When the pdb debugger starts, you will see a (Pdb) prompt. You must
2300 first enter 'c' (without qoutes) to start execution up to the first
2311 first enter 'c' (without qoutes) to start execution up to the first
2301 breakpoint.
2312 breakpoint.
2302
2313
2303 Entering 'help' gives information about the use of the debugger. You can
2314 Entering 'help' gives information about the use of the debugger. You can
2304 easily see pdb's full documentation with "import pdb;pdb.help()" at a
2315 easily see pdb's full documentation with "import pdb;pdb.help()" at a
2305 prompt.
2316 prompt.
2306
2317
2307 -p: run program under the control of the Python profiler module (which
2318 -p: run program under the control of the Python profiler module (which
2308 prints a detailed report of execution times, function calls, etc).
2319 prints a detailed report of execution times, function calls, etc).
2309
2320
2310 You can pass other options after -p which affect the behavior of the
2321 You can pass other options after -p which affect the behavior of the
2311 profiler itself. See the docs for %prun for details.
2322 profiler itself. See the docs for %prun for details.
2312
2323
2313 In this mode, the program's variables do NOT propagate back to the
2324 In this mode, the program's variables do NOT propagate back to the
2314 IPython interactive namespace (because they remain in the namespace
2325 IPython interactive namespace (because they remain in the namespace
2315 where the profiler executes them).
2326 where the profiler executes them).
2316
2327
2317 Internally this triggers a call to %prun, see its documentation for
2328 Internally this triggers a call to %prun, see its documentation for
2318 details on the options available specifically for profiling.
2329 details on the options available specifically for profiling.
2319
2330
2320 There is one special usage for which the text above doesn't apply: if
2331 There is one special usage for which the text above doesn't apply: if
2321 the filename ends with .ipy, the file is run as ipython script, just as
2332 the filename ends with .ipy, the file is run as ipython script, just as
2322 if the commands were written on IPython prompt.
2333 if the commands were written on IPython prompt.
2323
2334
2324
2335
2325 %runlog: Run files as logs.
2336 %runlog: Run files as logs.
2326
2337
2327 Usage:
2338 Usage:
2328 %runlog file1 file2 ...
2339 %runlog file1 file2 ...
2329
2340
2330 Run the named files (treating them as log files) in sequence inside the
2341 Run the named files (treating them as log files) in sequence inside the
2331 interpreter, and return to the prompt. This is much slower than %run
2342 interpreter, and return to the prompt. This is much slower than %run
2332 because each line is executed in a try/except block, but it allows
2343 because each line is executed in a try/except block, but it allows
2333 running files with syntax errors in them.
2344 running files with syntax errors in them.
2334
2345
2335 Normally IPython will guess when a file is one of its own logfiles, so
2346 Normally IPython will guess when a file is one of its own logfiles, so
2336 you can typically use %run even for logs. This shorthand allows you to
2347 you can typically use %run even for logs. This shorthand allows you to
2337 force any file to be treated as a log file.
2348 force any file to be treated as a log file.
2338
2349
2339
2350
2340 %save: Save a set of lines to a given filename.
2351 %save: Save a set of lines to a given filename.
2341
2352
2342 Usage:
2353 Usage:
2343 %save [options] filename n1-n2 n3-n4 ... n5 .. n6 ...
2354 %save [options] filename n1-n2 n3-n4 ... n5 .. n6 ...
2344
2355
2345 Options:
2356 Options:
2346
2357
2347 -r: use 'raw' input. By default, the 'processed' history is used, so
2358 -r: use 'raw' input. By default, the 'processed' history is used, so
2348 that magics are loaded in their transformed version to valid Python. If
2359 that magics are loaded in their transformed version to valid Python. If
2349 this option is given, the raw input as typed as the command line is used
2360 this option is given, the raw input as typed as the command line is used
2350 instead.
2361 instead.
2351
2362
2352 This function uses the same syntax as %macro for line extraction, but
2363 This function uses the same syntax as %macro for line extraction, but
2353 instead of creating a macro it saves the resulting string to the
2364 instead of creating a macro it saves the resulting string to the
2354 filename you specify.
2365 filename you specify.
2355
2366
2356 It adds a '.py' extension to the file if you don't do so yourself, and
2367 It adds a '.py' extension to the file if you don't do so yourself, and
2357 it asks for confirmation before overwriting existing files.
2368 it asks for confirmation before overwriting existing files.
2358
2369
2359
2370
2360 %sc: Shell capture - execute a shell command and capture its output.
2371 %sc: Shell capture - execute a shell command and capture its output.
2361
2372
2362 DEPRECATED. Suboptimal, retained for backwards compatibility.
2373 DEPRECATED. Suboptimal, retained for backwards compatibility.
2363
2374
2364 You should use the form 'var = !command' instead. Example:
2375 You should use the form 'var = !command' instead. Example:
2365
2376
2366 "%sc -l myfiles = ls " should now be written as
2377 "%sc -l myfiles = ls " should now be written as
2367
2378
2368 "myfiles = !ls "
2379 "myfiles = !ls "
2369
2380
2370 myfiles.s, myfiles.l and myfiles.n still apply as documented below.
2381 myfiles.s, myfiles.l and myfiles.n still apply as documented below.
2371
2382
2372 - %sc [options] varname=command
2383 - %sc [options] varname=command
2373
2384
2374 IPython will run the given command using commands.getoutput(), and will
2385 IPython will run the given command using commands.getoutput(), and will
2375 then update the user's interactive namespace with a variable called
2386 then update the user's interactive namespace with a variable called
2376 varname, containing the value of the call. Your command can contain
2387 varname, containing the value of the call. Your command can contain
2377 shell wildcards, pipes, etc.
2388 shell wildcards, pipes, etc.
2378
2389
2379 The '=' sign in the syntax is mandatory, and the variable name you
2390 The '=' sign in the syntax is mandatory, and the variable name you
2380 supply must follow Python's standard conventions for valid names.
2391 supply must follow Python's standard conventions for valid names.
2381
2392
2382 (A special format without variable name exists for internal use)
2393 (A special format without variable name exists for internal use)
2383
2394
2384 Options:
2395 Options:
2385
2396
2386 -l: list output. Split the output on newlines into a list before
2397 -l: list output. Split the output on newlines into a list before
2387 assigning it to the given variable. By default the output is stored as a
2398 assigning it to the given variable. By default the output is stored as a
2388 single string.
2399 single string.
2389
2400
2390 -v: verbose. Print the contents of the variable.
2401 -v: verbose. Print the contents of the variable.
2391
2402
2392 In most cases you should not need to split as a list, because the
2403 In most cases you should not need to split as a list, because the
2393 returned value is a special type of string which can automatically
2404 returned value is a special type of string which can automatically
2394 provide its contents either as a list (split on newlines) or as a
2405 provide its contents either as a list (split on newlines) or as a
2395 space-separated string. These are convenient, respectively, either for
2406 space-separated string. These are convenient, respectively, either for
2396 sequential processing or to be passed to a shell command.
2407 sequential processing or to be passed to a shell command.
2397
2408
2398 For example:
2409 For example:
2399
2410
2400 # Capture into variable a In [9]: sc a=ls *py
2411 # Capture into variable a In [9]: sc a=ls *py
2401
2412
2402 # a is a string with embedded newlines In [10]: a Out[10]: 'setup.py
2413 # a is a string with embedded newlines In [10]: a Out[10]: 'setup.py
2403 win32_manual_post_install.py'
2414 win32_manual_post_install.py'
2404
2415
2405 # which can be seen as a list: In [11]: a.l Out[11]: ['setup.py',
2416 # which can be seen as a list: In [11]: a.l Out[11]: ['setup.py',
2406 'win32_manual_post_install.py']
2417 'win32_manual_post_install.py']
2407
2418
2408 # or as a whitespace-separated string: In [12]: a.s Out[12]: 'setup.py
2419 # or as a whitespace-separated string: In [12]: a.s Out[12]: 'setup.py
2409 win32_manual_post_install.py'
2420 win32_manual_post_install.py'
2410
2421
2411 # a.s is useful to pass as a single command line: In [13]: !wc -l $a.s
2422 # a.s is useful to pass as a single command line: In [13]: !wc -l $a.s
2412 146 setup.py 130 win32_manual_post_install.py 276 total
2423 146 setup.py 130 win32_manual_post_install.py 276 total
2413
2424
2414 # while the list form is useful to loop over: In [14]: for f in a.l:
2425 # while the list form is useful to loop over: In [14]: for f in a.l:
2415 ....: !wc -l $f ....: 146 setup.py 130 win32_manual_post_install.py
2426 ....: !wc -l $f ....: 146 setup.py 130 win32_manual_post_install.py
2416
2427
2417 Similiarly, the lists returned by the -l option are also special, in the
2428 Similiarly, the lists returned by the -l option are also special, in the
2418 sense that you can equally invoke the .s attribute on them to
2429 sense that you can equally invoke the .s attribute on them to
2419 automatically get a whitespace-separated string from their contents:
2430 automatically get a whitespace-separated string from their contents:
2420
2431
2421 In [1]: sc -l b=ls *py
2432 In [1]: sc -l b=ls *py
2422
2433
2423 In [2]: b Out[2]: ['setup.py', 'win32_manual_post_install.py']
2434 In [2]: b Out[2]: ['setup.py', 'win32_manual_post_install.py']
2424
2435
2425 In [3]: b.s Out[3]: 'setup.py win32_manual_post_install.py'
2436 In [3]: b.s Out[3]: 'setup.py win32_manual_post_install.py'
2426
2437
2427 In summary, both the lists and strings used for ouptut capture have the
2438 In summary, both the lists and strings used for ouptut capture have the
2428 following special attributes:
2439 following special attributes:
2429
2440
2430 .l (or .list) : value as list. .n (or .nlstr): value as
2441 .l (or .list) : value as list. .n (or .nlstr): value as
2431 newline-separated string. .s (or .spstr): value as space-separated string.
2442 newline-separated string. .s (or .spstr): value as space-separated string.
2432
2443
2433
2444
2434 %sx: Shell execute - run a shell command and capture its output.
2445 %sx: Shell execute - run a shell command and capture its output.
2435
2446
2436 %sx command
2447 %sx command
2437
2448
2438 IPython will run the given command using commands.getoutput(), and
2449 IPython will run the given command using commands.getoutput(), and
2439 return the result formatted as a list (split on '\n'). Since the output
2450 return the result formatted as a list (split on '\n'). Since the output
2440 is _returned_, it will be stored in ipython's regular output cache
2451 is _returned_, it will be stored in ipython's regular output cache
2441 Out[N] and in the '_N' automatic variables.
2452 Out[N] and in the '_N' automatic variables.
2442
2453
2443 Notes:
2454 Notes:
2444
2455
2445 1) If an input line begins with '!!', then %sx is automatically invoked.
2456 1) If an input line begins with '!!', then %sx is automatically invoked.
2446 That is, while: !ls causes ipython to simply issue system('ls'), typing
2457 That is, while: !ls causes ipython to simply issue system('ls'), typing
2447 !!ls is a shorthand equivalent to: %sx ls
2458 !!ls is a shorthand equivalent to: %sx ls
2448
2459
2449 2) %sx differs from %sc in that %sx automatically splits into a list,
2460 2) %sx differs from %sc in that %sx automatically splits into a list,
2450 like '%sc -l'. The reason for this is to make it as easy as possible to
2461 like '%sc -l'. The reason for this is to make it as easy as possible to
2451 process line-oriented shell output via further python commands. %sc is
2462 process line-oriented shell output via further python commands. %sc is
2452 meant to provide much finer control, but requires more typing.
2463 meant to provide much finer control, but requires more typing.
2453
2464
2454 3) Just like %sc -l, this is a list with special attributes:
2465 3) Just like %sc -l, this is a list with special attributes:
2455
2466
2456 .l (or .list) : value as list. .n (or .nlstr): value as
2467 .l (or .list) : value as list. .n (or .nlstr): value as
2457 newline-separated string. .s (or .spstr): value as whitespace-separated
2468 newline-separated string. .s (or .spstr): value as whitespace-separated
2458 string.
2469 string.
2459
2470
2460 This is very useful when trying to use such lists as arguments to system
2471 This is very useful when trying to use such lists as arguments to system
2461 commands.
2472 commands.
2462
2473
2463
2474
2464 %system_verbose: Set verbose printing of system calls.
2475 %system_verbose: Set verbose printing of system calls.
2465
2476
2466 If called without an argument, act as a toggle
2477 If called without an argument, act as a toggle
2467
2478
2468
2479
2469 %time: Time execution of a Python statement or expression.
2480 %time: Time execution of a Python statement or expression.
2470
2481
2471 The CPU and wall clock times are printed, and the value of the
2482 The CPU and wall clock times are printed, and the value of the
2472 expression (if any) is returned. Note that under Win32, system time is
2483 expression (if any) is returned. Note that under Win32, system time is
2473 always reported as 0, since it can not be measured.
2484 always reported as 0, since it can not be measured.
2474
2485
2475 This function provides very basic timing functionality. In Python 2.3,
2486 This function provides very basic timing functionality. In Python 2.3,
2476 the timeit module offers more control and sophistication, so this could
2487 the timeit module offers more control and sophistication, so this could
2477 be rewritten to use it (patches welcome).
2488 be rewritten to use it (patches welcome).
2478
2489
2479 Some examples:
2490 Some examples:
2480
2491
2481 In [1]: time 2**128 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
2492 In [1]: time 2**128 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
2482 Wall time: 0.00 Out[1]: 340282366920938463463374607431768211456L
2493 Wall time: 0.00 Out[1]: 340282366920938463463374607431768211456L
2483
2494
2484 In [2]: n = 1000000
2495 In [2]: n = 1000000
2485
2496
2486 In [3]: time sum(range(n)) CPU times: user 1.20 s, sys: 0.05 s, total:
2497 In [3]: time sum(range(n)) CPU times: user 1.20 s, sys: 0.05 s, total:
2487 1.25 s Wall time: 1.37 Out[3]: 499999500000L
2498 1.25 s Wall time: 1.37 Out[3]: 499999500000L
2488
2499
2489 In [4]: time print 'hello world' hello world CPU times: user 0.00 s,
2500 In [4]: time print 'hello world' hello world CPU times: user 0.00 s,
2490 sys: 0.00 s, total: 0.00 s Wall time: 0.00
2501 sys: 0.00 s, total: 0.00 s Wall time: 0.00
2491
2502
2492 Note that the time needed by Python to compile the given expression will
2503 Note that the time needed by Python to compile the given expression will
2493 be reported if it is more than 0.1s. In this example, the actual
2504 be reported if it is more than 0.1s. In this example, the actual
2494 exponentiation is done by Python at compilation time, so while the
2505 exponentiation is done by Python at compilation time, so while the
2495 expression can take a noticeable amount of time to compute, that time is
2506 expression can take a noticeable amount of time to compute, that time is
2496 purely due to the compilation:
2507 purely due to the compilation:
2497
2508
2498 In [5]: time 3**9999; CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
2509 In [5]: time 3**9999; CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
2499 Wall time: 0.00 s
2510 Wall time: 0.00 s
2500
2511
2501 In [6]: time 3**999999; CPU times: user 0.00 s, sys: 0.00 s, total: 0.00
2512 In [6]: time 3**999999; CPU times: user 0.00 s, sys: 0.00 s, total: 0.00
2502 s Wall time: 0.00 s Compiler : 0.78 s
2513 s Wall time: 0.00 s Compiler : 0.78 s
2503
2514
2504
2515
2505 %timeit: Time execution of a Python statement or expression
2516 %timeit: Time execution of a Python statement or expression
2506
2517
2507 Usage:
2518 Usage:
2508 %timeit [-n<N> -r<R> [-t|-c]] statement
2519 %timeit [-n<N> -r<R> [-t|-c]] statement
2509
2520
2510 Time execution of a Python statement or expression using the timeit module.
2521 Time execution of a Python statement or expression using the timeit module.
2511
2522
2512 Options: -n<N>: execute the given statement <N> times in a loop. If this
2523 Options: -n<N>: execute the given statement <N> times in a loop. If this
2513 value is not given, a fitting value is chosen.
2524 value is not given, a fitting value is chosen.
2514
2525
2515 -r<R>: repeat the loop iteration <R> times and take the best result.
2526 -r<R>: repeat the loop iteration <R> times and take the best result.
2516 Default: 3
2527 Default: 3
2517
2528
2518 -t: use time.time to measure the time, which is the default on Unix.
2529 -t: use time.time to measure the time, which is the default on Unix.
2519 This function measures wall time.
2530 This function measures wall time.
2520
2531
2521 -c: use time.clock to measure the time, which is the default on Windows
2532 -c: use time.clock to measure the time, which is the default on Windows
2522 and measures wall time. On Unix, resource.getrusage is used instead and
2533 and measures wall time. On Unix, resource.getrusage is used instead and
2523 returns the CPU user time.
2534 returns the CPU user time.
2524
2535
2525 -p<P>: use a precision of <P> digits to display the timing result.
2536 -p<P>: use a precision of <P> digits to display the timing result.
2526 Default: 3
2537 Default: 3
2527
2538
2528 Examples:
2539 Examples:
2529 In [1]: %timeit pass 10000000 loops, best of 3: 53.3 ns per loop
2540 In [1]: %timeit pass 10000000 loops, best of 3: 53.3 ns per loop
2530
2541
2531 In [2]: u = None
2542 In [2]: u = None
2532
2543
2533 In [3]: %timeit u is None 10000000 loops, best of 3: 184 ns per loop
2544 In [3]: %timeit u is None 10000000 loops, best of 3: 184 ns per loop
2534
2545
2535 In [4]: %timeit -r 4 u == None 1000000 loops, best of 4: 242 ns per loop
2546 In [4]: %timeit -r 4 u == None 1000000 loops, best of 4: 242 ns per loop
2536
2547
2537 In [5]: import time
2548 In [5]: import time
2538
2549
2539 In [6]: %timeit -n1 time.sleep(2) 1 loops, best of 3: 2 s per loop
2550 In [6]: %timeit -n1 time.sleep(2) 1 loops, best of 3: 2 s per loop
2540
2551
2541 The times reported by %timeit will be slightly higher than those
2552 The times reported by %timeit will be slightly higher than those
2542 reported by the timeit.py script when variables are accessed. This is
2553 reported by the timeit.py script when variables are accessed. This is
2543 due to the fact that %timeit executes the statement in the namespace of
2554 due to the fact that %timeit executes the statement in the namespace of
2544 the shell, compared with timeit.py, which uses a single setup statement
2555 the shell, compared with timeit.py, which uses a single setup statement
2545 to import function or create variables. Generally, the bias does not
2556 to import function or create variables. Generally, the bias does not
2546 matter as long as results from timeit.py are not mixed with those from
2557 matter as long as results from timeit.py are not mixed with those from
2547 %timeit.
2558 %timeit.
2548
2559
2549
2560
2550 %unalias: Remove an alias
2561 %unalias: Remove an alias
2551
2562
2552
2563
2553 %upgrade: Upgrade your IPython installation
2564 %upgrade: Upgrade your IPython installation
2554
2565
2555 This will copy the config files that don't yet exist in your ipython dir
2566 This will copy the config files that don't yet exist in your ipython dir
2556 from the system config dir. Use this after upgrading IPython if you
2567 from the system config dir. Use this after upgrading IPython if you
2557 don't wish to delete your .ipython dir.
2568 don't wish to delete your .ipython dir.
2558
2569
2559 Call with -nolegacy to get rid of ipythonrc* files (recommended for new
2570 Call with -nolegacy to get rid of ipythonrc* files (recommended for new
2560 users)
2571 users)
2561
2572
2562
2573
2563 %who: Print all interactive variables, with some minimal formatting.
2574 %who: Print all interactive variables, with some minimal formatting.
2564
2575
2565 If any arguments are given, only variables whose type matches one of
2576 If any arguments are given, only variables whose type matches one of
2566 these are printed. For example:
2577 these are printed. For example:
2567
2578
2568 %who function str
2579 %who function str
2569
2580
2570 will only list functions and strings, excluding all other types of
2581 will only list functions and strings, excluding all other types of
2571 variables. To find the proper type names, simply use type(var) at a
2582 variables. To find the proper type names, simply use type(var) at a
2572 command line to see how python prints type names. For example:
2583 command line to see how python prints type names. For example:
2573
2584
2574 In [1]: type('hello')
2585 In [1]: type('hello')
2575 Out[1]: <type 'str'>
2586 Out[1]: <type 'str'>
2576
2587
2577 indicates that the type name for strings is 'str'.
2588 indicates that the type name for strings is 'str'.
2578
2589
2579 %who always excludes executed names loaded through your configuration
2590 %who always excludes executed names loaded through your configuration
2580 file and things which are internal to IPython.
2591 file and things which are internal to IPython.
2581
2592
2582 This is deliberate, as typically you may load many modules and the
2593 This is deliberate, as typically you may load many modules and the
2583 purpose of %who is to show you only what you've manually defined.
2594 purpose of %who is to show you only what you've manually defined.
2584
2595
2585
2596
2586 %who_ls: Return a sorted list of all interactive variables.
2597 %who_ls: Return a sorted list of all interactive variables.
2587
2598
2588 If arguments are given, only variables of types matching these arguments
2599 If arguments are given, only variables of types matching these arguments
2589 are returned.
2600 are returned.
2590
2601
2591
2602
2592 %whos: Like %who, but gives some extra information about each variable.
2603 %whos: Like %who, but gives some extra information about each variable.
2593
2604
2594 The same type filtering of %who can be applied here.
2605 The same type filtering of %who can be applied here.
2595
2606
2596 For all variables, the type is printed. Additionally it prints:
2607 For all variables, the type is printed. Additionally it prints:
2597
2608
2598 - For ,[],(): their length.
2609 - For ,[],(): their length.
2599
2610
2600 - For numpy and Numeric arrays, a summary with shape, number of
2611 - For numpy and Numeric arrays, a summary with shape, number of
2601 elements, typecode and size in memory.
2612 elements, typecode and size in memory.
2602
2613
2603 - Everything else: a string representation, snipping their middle if too
2614 - Everything else: a string representation, snipping their middle if too
2604 long.
2615 long.
2605
2616
2606
2617
2607 %xmode: Switch modes for the exception handlers.
2618 %xmode: Switch modes for the exception handlers.
2608
2619
2609 Valid modes: Plain, Context and Verbose.
2620 Valid modes: Plain, Context and Verbose.
2610
2621
2611 If called without arguments, acts as a toggle.
2622 If called without arguments, acts as a toggle.
2612
2623
2613
2624
2614 Access to the standard Python help
2625 Access to the standard Python help
2615 ----------------------------------
2626 ----------------------------------
2616
2627
2617 As of Python 2.1, a help system is available with access to object
2628 As of Python 2.1, a help system is available with access to object
2618 docstrings and the Python manuals. Simply type 'help' (no quotes) to
2629 docstrings and the Python manuals. Simply type 'help' (no quotes) to
2619 access it. You can also type help(object) to obtain information about a
2630 access it. You can also type help(object) to obtain information about a
2620 given object, and help('keyword') for information on a keyword. As noted
2631 given object, and help('keyword') for information on a keyword. As noted
2621 in sec. 3.1 <node3.html#sec:help-access>, you need to properly configure
2632 in sec. 3.1 <node3.html#sec:help-access>, you need to properly configure
2622 your environment variable PYTHONDOCS for this feature to work correctly.
2633 your environment variable PYTHONDOCS for this feature to work correctly.
2623
2634
2624
2635
2625
2636
2626 Dynamic object information
2637 Dynamic object information
2627 --------------------------
2638 --------------------------
2628
2639
2629 Typing ?word or word? prints detailed information about an object. If
2640 Typing ?word or word? prints detailed information about an object. If
2630 certain strings in the object are too long (docstrings, code, etc.) they
2641 certain strings in the object are too long (docstrings, code, etc.) they
2631 get snipped in the center for brevity. This system gives access variable
2642 get snipped in the center for brevity. This system gives access variable
2632 types and values, full source code for any object (if available),
2643 types and values, full source code for any object (if available),
2633 function prototypes and other useful information.
2644 function prototypes and other useful information.
2634
2645
2635 Typing ??word or word?? gives access to the full information without
2646 Typing ??word or word?? gives access to the full information without
2636 snipping long strings. Long strings are sent to the screen through the
2647 snipping long strings. Long strings are sent to the screen through the
2637 less pager if longer than the screen and printed otherwise. On systems
2648 less pager if longer than the screen and printed otherwise. On systems
2638 lacking the less command, IPython uses a very basic internal pager.
2649 lacking the less command, IPython uses a very basic internal pager.
2639
2650
2640 The following magic functions are particularly useful for gathering
2651 The following magic functions are particularly useful for gathering
2641 information about your working environment. You can get more details by
2652 information about your working environment. You can get more details by
2642 typing %magic or querying them individually (use %function_name? with or
2653 typing %magic or querying them individually (use %function_name? with or
2643 without the %), this is just a summary:
2654 without the %), this is just a summary:
2644
2655
2645 * [%pdoc <object>:] Print (or run through a pager if too long) the
2656 * [%pdoc <object>:] Print (or run through a pager if too long) the
2646 docstring for an object. If the given object is a class, it will
2657 docstring for an object. If the given object is a class, it will
2647 print both the class and the constructor docstrings.
2658 print both the class and the constructor docstrings.
2648 * [%pdef <object>:] Print the definition header for any callable
2659 * [%pdef <object>:] Print the definition header for any callable
2649 object. If the object is a class, print the constructor information.
2660 object. If the object is a class, print the constructor information.
2650 * [%psource <object>:] Print (or run through a pager if too long)
2661 * [%psource <object>:] Print (or run through a pager if too long)
2651 the source code for an object.
2662 the source code for an object.
2652 * [%pfile <object>:] Show the entire source file where an object was
2663 * [%pfile <object>:] Show the entire source file where an object was
2653 defined via a pager, opening it at the line where the object
2664 defined via a pager, opening it at the line where the object
2654 definition begins.
2665 definition begins.
2655 * [%who/%whos:] These functions give information about identifiers
2666 * [%who/%whos:] These functions give information about identifiers
2656 you have defined interactively (not things you loaded or defined
2667 you have defined interactively (not things you loaded or defined
2657 in your configuration files). %who just prints a list of
2668 in your configuration files). %who just prints a list of
2658 identifiers and %whos prints a table with some basic details about
2669 identifiers and %whos prints a table with some basic details about
2659 each identifier.
2670 each identifier.
2660
2671
2661 Note that the dynamic object information functions (?/??, %pdoc, %pfile,
2672 Note that the dynamic object information functions (?/??, %pdoc, %pfile,
2662 %pdef, %psource) give you access to documentation even on things which
2673 %pdef, %psource) give you access to documentation even on things which
2663 are not really defined as separate identifiers. Try for example typing
2674 are not really defined as separate identifiers. Try for example typing
2664 {}.get? or after doing import os, type os.path.abspath??.
2675 {}.get? or after doing import os, type os.path.abspath??.
2665
2676
2666
2677
2667
2678
2668 Readline-based features
2679 Readline-based features
2669 -----------------------
2680 -----------------------
2670
2681
2671 These features require the GNU readline library, so they won't work if
2682 These features require the GNU readline library, so they won't work if
2672 your Python installation lacks readline support. We will first describe
2683 your Python installation lacks readline support. We will first describe
2673 the default behavior IPython uses, and then how to change it to suit
2684 the default behavior IPython uses, and then how to change it to suit
2674 your preferences.
2685 your preferences.
2675
2686
2676
2687
2677 Command line completion
2688 Command line completion
2678 -----------------------
2689 -----------------------
2679
2690
2680 At any time, hitting TAB will complete any available python commands or
2691 At any time, hitting TAB will complete any available python commands or
2681 variable names, and show you a list of the possible completions if
2692 variable names, and show you a list of the possible completions if
2682 there's no unambiguous one. It will also complete filenames in the
2693 there's no unambiguous one. It will also complete filenames in the
2683 current directory if no python names match what you've typed so far.
2694 current directory if no python names match what you've typed so far.
2684
2695
2685
2696
2686 Search command history
2697 Search command history
2687 ----------------------
2698 ----------------------
2688
2699
2689 IPython provides two ways for searching through previous input and thus
2700 IPython provides two ways for searching through previous input and thus
2690 reduce the need for repetitive typing:
2701 reduce the need for repetitive typing:
2691
2702
2692 1. Start typing, and then use Ctrl-p (previous,up) and Ctrl-n
2703 1. Start typing, and then use Ctrl-p (previous,up) and Ctrl-n
2693 (next,down) to search through only the history items that match
2704 (next,down) to search through only the history items that match
2694 what you've typed so far. If you use Ctrl-p/Ctrl-n at a blank
2705 what you've typed so far. If you use Ctrl-p/Ctrl-n at a blank
2695 prompt, they just behave like normal arrow keys.
2706 prompt, they just behave like normal arrow keys.
2696 2. Hit Ctrl-r: opens a search prompt. Begin typing and the system
2707 2. Hit Ctrl-r: opens a search prompt. Begin typing and the system
2697 searches your history for lines that contain what you've typed so
2708 searches your history for lines that contain what you've typed so
2698 far, completing as much as it can.
2709 far, completing as much as it can.
2699
2710
2700
2711
2701 Persistent command history across sessions
2712 Persistent command history across sessions
2702 ------------------------------------------
2713 ------------------------------------------
2703
2714
2704 IPython will save your input history when it leaves and reload it next
2715 IPython will save your input history when it leaves and reload it next
2705 time you restart it. By default, the history file is named
2716 time you restart it. By default, the history file is named
2706 $IPYTHONDIR/history, but if you've loaded a named profile,
2717 $IPYTHONDIR/history, but if you've loaded a named profile,
2707 '-PROFILE_NAME' is appended to the name. This allows you to keep
2718 '-PROFILE_NAME' is appended to the name. This allows you to keep
2708 separate histories related to various tasks: commands related to
2719 separate histories related to various tasks: commands related to
2709 numerical work will not be clobbered by a system shell history, for
2720 numerical work will not be clobbered by a system shell history, for
2710 example.
2721 example.
2711
2722
2712
2723
2713 Autoindent
2724 Autoindent
2714 ----------
2725 ----------
2715
2726
2716 IPython can recognize lines ending in ':' and indent the next line,
2727 IPython can recognize lines ending in ':' and indent the next line,
2717 while also un-indenting automatically after 'raise' or 'return'.
2728 while also un-indenting automatically after 'raise' or 'return'.
2718
2729
2719 This feature uses the readline library, so it will honor your ~/.inputrc
2730 This feature uses the readline library, so it will honor your ~/.inputrc
2720 configuration (or whatever file your INPUTRC variable points to). Adding
2731 configuration (or whatever file your INPUTRC variable points to). Adding
2721 the following lines to your .inputrc file can make indenting/unindenting
2732 the following lines to your .inputrc file can make indenting/unindenting
2722 more convenient (M-i indents, M-u unindents)::
2733 more convenient (M-i indents, M-u unindents)::
2723
2734
2724 $if Python
2735 $if Python
2725 "\M-i": " "
2736 "\M-i": " "
2726 "\M-u": "\d\d\d\d"
2737 "\M-u": "\d\d\d\d"
2727 $endif
2738 $endif
2728
2739
2729 Note that there are 4 spaces between the quote marks after "M-i" above.
2740 Note that there are 4 spaces between the quote marks after "M-i" above.
2730
2741
2731 Warning: this feature is ON by default, but it can cause problems with
2742 Warning: this feature is ON by default, but it can cause problems with
2732 the pasting of multi-line indented code (the pasted code gets
2743 the pasting of multi-line indented code (the pasted code gets
2733 re-indented on each line). A magic function %autoindent allows you to
2744 re-indented on each line). A magic function %autoindent allows you to
2734 toggle it on/off at runtime. You can also disable it permanently on in
2745 toggle it on/off at runtime. You can also disable it permanently on in
2735 your ipythonrc file (set autoindent 0).
2746 your ipythonrc file (set autoindent 0).
2736
2747
2737
2748
2738 Customizing readline behavior
2749 Customizing readline behavior
2739 -----------------------------
2750 -----------------------------
2740
2751
2741 All these features are based on the GNU readline library, which has an
2752 All these features are based on the GNU readline library, which has an
2742 extremely customizable interface. Normally, readline is configured via a
2753 extremely customizable interface. Normally, readline is configured via a
2743 file which defines the behavior of the library; the details of the
2754 file which defines the behavior of the library; the details of the
2744 syntax for this can be found in the readline documentation available
2755 syntax for this can be found in the readline documentation available
2745 with your system or on the Internet. IPython doesn't read this file (if
2756 with your system or on the Internet. IPython doesn't read this file (if
2746 it exists) directly, but it does support passing to readline valid
2757 it exists) directly, but it does support passing to readline valid
2747 options via a simple interface. In brief, you can customize readline by
2758 options via a simple interface. In brief, you can customize readline by
2748 setting the following options in your ipythonrc configuration file (note
2759 setting the following options in your ipythonrc configuration file (note
2749 that these options can not be specified at the command line):
2760 that these options can not be specified at the command line):
2750
2761
2751 * [readline_parse_and_bind:] this option can appear as many times as
2762 * [readline_parse_and_bind:] this option can appear as many times as
2752 you want, each time defining a string to be executed via a
2763 you want, each time defining a string to be executed via a
2753 readline.parse_and_bind() command. The syntax for valid commands
2764 readline.parse_and_bind() command. The syntax for valid commands
2754 of this kind can be found by reading the documentation for the GNU
2765 of this kind can be found by reading the documentation for the GNU
2755 readline library, as these commands are of the kind which readline
2766 readline library, as these commands are of the kind which readline
2756 accepts in its configuration file.
2767 accepts in its configuration file.
2757 * [readline_remove_delims:] a string of characters to be removed
2768 * [readline_remove_delims:] a string of characters to be removed
2758 from the default word-delimiters list used by readline, so that
2769 from the default word-delimiters list used by readline, so that
2759 completions may be performed on strings which contain them. Do not
2770 completions may be performed on strings which contain them. Do not
2760 change the default value unless you know what you're doing.
2771 change the default value unless you know what you're doing.
2761 * [readline_omit__names:] when tab-completion is enabled, hitting
2772 * [readline_omit__names:] when tab-completion is enabled, hitting
2762 <tab> after a '.' in a name will complete all attributes of an
2773 <tab> after a '.' in a name will complete all attributes of an
2763 object, including all the special methods whose names include
2774 object, including all the special methods whose names include
2764 double underscores (like __getitem__ or __class__). If you'd
2775 double underscores (like __getitem__ or __class__). If you'd
2765 rather not see these names by default, you can set this option to
2776 rather not see these names by default, you can set this option to
2766 1. Note that even when this option is set, you can still see those
2777 1. Note that even when this option is set, you can still see those
2767 names by explicitly typing a _ after the period and hitting <tab>:
2778 names by explicitly typing a _ after the period and hitting <tab>:
2768 'name._<tab>' will always complete attribute names starting with '_'.
2779 'name._<tab>' will always complete attribute names starting with '_'.
2769 * [ ] This option is off by default so that new users see all
2780 * [ ] This option is off by default so that new users see all
2770 attributes of any objects they are dealing with.
2781 attributes of any objects they are dealing with.
2771
2782
2772 You will find the default values along with a corresponding detailed
2783 You will find the default values along with a corresponding detailed
2773 explanation in your ipythonrc file.
2784 explanation in your ipythonrc file.
2774
2785
2775
2786
2776 Session logging and restoring
2787 Session logging and restoring
2777 -----------------------------
2788 -----------------------------
2778
2789
2779 You can log all input from a session either by starting IPython with the
2790 You can log all input from a session either by starting IPython with the
2780 command line switches -log or -logfile (see sec. 5.2
2791 command line switches -log or -logfile (see sec. 5.2
2781 <node5.html#sec:cmd-line-opts>)or by activating the logging at any
2792 <node5.html#sec:cmd-line-opts>)or by activating the logging at any
2782 moment with the magic function %logstart.
2793 moment with the magic function %logstart.
2783
2794
2784 Log files can later be reloaded with the -logplay option and IPython
2795 Log files can later be reloaded with the -logplay option and IPython
2785 will attempt to 'replay' the log by executing all the lines in it, thus
2796 will attempt to 'replay' the log by executing all the lines in it, thus
2786 restoring the state of a previous session. This feature is not quite
2797 restoring the state of a previous session. This feature is not quite
2787 perfect, but can still be useful in many cases.
2798 perfect, but can still be useful in many cases.
2788
2799
2789 The log files can also be used as a way to have a permanent record of
2800 The log files can also be used as a way to have a permanent record of
2790 any code you wrote while experimenting. Log files are regular text files
2801 any code you wrote while experimenting. Log files are regular text files
2791 which you can later open in your favorite text editor to extract code or
2802 which you can later open in your favorite text editor to extract code or
2792 to 'clean them up' before using them to replay a session.
2803 to 'clean them up' before using them to replay a session.
2793
2804
2794 The %logstart function for activating logging in mid-session is used as
2805 The %logstart function for activating logging in mid-session is used as
2795 follows:
2806 follows:
2796
2807
2797 %logstart [log_name [log_mode]]
2808 %logstart [log_name [log_mode]]
2798
2809
2799 If no name is given, it defaults to a file named 'log' in your
2810 If no name is given, it defaults to a file named 'log' in your
2800 IPYTHONDIR directory, in 'rotate' mode (see below).
2811 IPYTHONDIR directory, in 'rotate' mode (see below).
2801
2812
2802 '%logstart name' saves to file 'name' in 'backup' mode. It saves your
2813 '%logstart name' saves to file 'name' in 'backup' mode. It saves your
2803 history up to that point and then continues logging.
2814 history up to that point and then continues logging.
2804
2815
2805 %logstart takes a second optional parameter: logging mode. This can be
2816 %logstart takes a second optional parameter: logging mode. This can be
2806 one of (note that the modes are given unquoted):
2817 one of (note that the modes are given unquoted):
2807
2818
2808 * [over:] overwrite existing log_name.
2819 * [over:] overwrite existing log_name.
2809 * [backup:] rename (if exists) to log_name~ and start log_name.
2820 * [backup:] rename (if exists) to log_name~ and start log_name.
2810 * [append:] well, that says it.
2821 * [append:] well, that says it.
2811 * [rotate:] create rotating logs log_name.1~, log_name.2~, etc.
2822 * [rotate:] create rotating logs log_name.1~, log_name.2~, etc.
2812
2823
2813 The %logoff and %logon functions allow you to temporarily stop and
2824 The %logoff and %logon functions allow you to temporarily stop and
2814 resume logging to a file which had previously been started with
2825 resume logging to a file which had previously been started with
2815 %logstart. They will fail (with an explanation) if you try to use them
2826 %logstart. They will fail (with an explanation) if you try to use them
2816 before logging has been started.
2827 before logging has been started.
2817
2828
2818
2829
2819
2830
2820 System shell access
2831 System shell access
2821 -------------------
2832 -------------------
2822
2833
2823 Any input line beginning with a ! character is passed verbatim (minus
2834 Any input line beginning with a ! character is passed verbatim (minus
2824 the !, of course) to the underlying operating system. For example,
2835 the !, of course) to the underlying operating system. For example,
2825 typing !ls will run 'ls' in the current directory.
2836 typing !ls will run 'ls' in the current directory.
2826
2837
2827
2828 Manual capture of command output
2838 Manual capture of command output
2829 --------------------------------
2839 --------------------------------
2830
2840
2831 If the input line begins with two exclamation marks, !!, the command is
2841 If the input line begins with two exclamation marks, !!, the command is
2832 executed but its output is captured and returned as a python list, split
2842 executed but its output is captured and returned as a python list, split
2833 on newlines. Any output sent by the subprocess to standard error is
2843 on newlines. Any output sent by the subprocess to standard error is
2834 printed separately, so that the resulting list only captures standard
2844 printed separately, so that the resulting list only captures standard
2835 output. The !! syntax is a shorthand for the %sx magic command.
2845 output. The !! syntax is a shorthand for the %sx magic command.
2836
2846
2837 Finally, the %sc magic (short for 'shell capture') is similar to %sx,
2847 Finally, the %sc magic (short for 'shell capture') is similar to %sx,
2838 but allowing more fine-grained control of the capture details, and
2848 but allowing more fine-grained control of the capture details, and
2839 storing the result directly into a named variable.
2849 storing the result directly into a named variable. The direct use of
2840
2850 %sc is now deprecated, and you should ise the ``var = !cmd`` syntax
2841 See Sec. 6.2 <#sec:magic> for details on the magics %sc and %sx, or use
2851 instead.
2842 IPython's own help (sc? and sx?) for further details.
2843
2852
2844 IPython also allows you to expand the value of python variables when
2853 IPython also allows you to expand the value of python variables when
2845 making system calls. Any python variable or expression which you prepend
2854 making system calls. Any python variable or expression which you prepend
2846 with $ will get expanded before the system call is made::
2855 with $ will get expanded before the system call is made::
2847
2856
2848 In [1]: pyvar='Hello world'
2857 In [1]: pyvar='Hello world'
2849 In [2]: !echo "A python variable: $pyvar"
2858 In [2]: !echo "A python variable: $pyvar"
2850 A python variable: Hello world
2859 A python variable: Hello world
2851
2860
2852 If you want the shell to actually see a literal $, you need to type it
2861 If you want the shell to actually see a literal $, you need to type it
2853 twice::
2862 twice::
2854
2863
2855 In [3]: !echo "A system variable: $$HOME"
2864 In [3]: !echo "A system variable: $$HOME"
2856 A system variable: /home/fperez
2865 A system variable: /home/fperez
2857
2866
2858 You can pass arbitrary expressions, though you'll need to delimit them
2867 You can pass arbitrary expressions, though you'll need to delimit them
2859 with {} if there is ambiguity as to the extent of the expression::
2868 with {} if there is ambiguity as to the extent of the expression::
2860
2869
2861 In [5]: x=10
2870 In [5]: x=10
2862 In [6]: y=20
2871 In [6]: y=20
2863 In [13]: !echo $x+y
2872 In [13]: !echo $x+y
2864 10+y
2873 10+y
2865 In [7]: !echo ${x+y}
2874 In [7]: !echo ${x+y}
2866 30
2875 30
2867
2876
2868 Even object attributes can be expanded::
2877 Even object attributes can be expanded::
2869
2878
2870 In [12]: !echo $sys.argv
2879 In [12]: !echo $sys.argv
2871 [/home/fperez/usr/bin/ipython]
2880 [/home/fperez/usr/bin/ipython]
2872
2881
2873
2882
2874 System command aliases
2883 System command aliases
2875 ----------------------
2884 ----------------------
2876
2885
2877 The %alias magic function and the alias option in the ipythonrc
2886 The %alias magic function and the alias option in the ipythonrc
2878 configuration file allow you to define magic functions which are in fact
2887 configuration file allow you to define magic functions which are in fact
2879 system shell commands. These aliases can have parameters.
2888 system shell commands. These aliases can have parameters.
2880
2889
2881 '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
2890 '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
2882
2891
2883 Then, typing '%alias_name params' will execute the system command 'cmd
2892 Then, typing '%alias_name params' will execute the system command 'cmd
2884 params' (from your underlying operating system).
2893 params' (from your underlying operating system).
2885
2894
2886 You can also define aliases with parameters using %s specifiers (one per
2895 You can also define aliases with parameters using %s specifiers (one per
2887 parameter). The following example defines the %parts function as an
2896 parameter). The following example defines the %parts function as an
2888 alias to the command 'echo first %s second %s' where each %s will be
2897 alias to the command 'echo first %s second %s' where each %s will be
2889 replaced by a positional parameter to the call to %parts::
2898 replaced by a positional parameter to the call to %parts::
2890
2899
2891 In [1]: alias parts echo first %s second %s
2900 In [1]: alias parts echo first %s second %s
2892 In [2]: %parts A B
2901 In [2]: %parts A B
2893 first A second B
2902 first A second B
2894 In [3]: %parts A
2903 In [3]: %parts A
2895 Incorrect number of arguments: 2 expected.
2904 Incorrect number of arguments: 2 expected.
2896 parts is an alias to: 'echo first %s second %s'
2905 parts is an alias to: 'echo first %s second %s'
2897
2906
2898 If called with no parameters, %alias prints the table of currently
2907 If called with no parameters, %alias prints the table of currently
2899 defined aliases.
2908 defined aliases.
2900
2909
2901 The %rehash/rehashx magics allow you to load your entire $PATH as
2910 The %rehash/rehashx magics allow you to load your entire $PATH as
2902 ipython aliases. See their respective docstrings (or sec. 6.2
2911 ipython aliases. See their respective docstrings (or sec. 6.2
2903 <#sec:magic> for further details).
2912 <#sec:magic> for further details).
2904
2913
2905
2914
2906
2915
2907 Recursive reload
2916 Recursive reload
2908 ----------------
2917 ----------------
2909
2918
2910 The dreload function does a recursive reload of a module: changes made
2919 The dreload function does a recursive reload of a module: changes made
2911 to the module since you imported will actually be available without
2920 to the module since you imported will actually be available without
2912 having to exit.
2921 having to exit.
2913
2922
2914
2923
2915 Verbose and colored exception traceback printouts
2924 Verbose and colored exception traceback printouts
2916 -------------------------------------------------
2925 -------------------------------------------------
2917
2926
2918 IPython provides the option to see very detailed exception tracebacks,
2927 IPython provides the option to see very detailed exception tracebacks,
2919 which can be especially useful when debugging large programs. You can
2928 which can be especially useful when debugging large programs. You can
2920 run any Python file with the %run function to benefit from these
2929 run any Python file with the %run function to benefit from these
2921 detailed tracebacks. Furthermore, both normal and verbose tracebacks can
2930 detailed tracebacks. Furthermore, both normal and verbose tracebacks can
2922 be colored (if your terminal supports it) which makes them much easier
2931 be colored (if your terminal supports it) which makes them much easier
2923 to parse visually.
2932 to parse visually.
2924
2933
2925 See the magic xmode and colors functions for details (just type %magic).
2934 See the magic xmode and colors functions for details (just type %magic).
2926
2935
2927 These features are basically a terminal version of Ka-Ping Yee's cgitb
2936 These features are basically a terminal version of Ka-Ping Yee's cgitb
2928 module, now part of the standard Python library.
2937 module, now part of the standard Python library.
2929
2938
2930
2939
2931
2940
2932 Input caching system
2941 Input caching system
2933 --------------------
2942 --------------------
2934
2943
2935 IPython offers numbered prompts (In/Out) with input and output caching.
2944 IPython offers numbered prompts (In/Out) with input and output caching.
2936 All input is saved and can be retrieved as variables (besides the usual
2945 All input is saved and can be retrieved as variables (besides the usual
2937 arrow key recall).
2946 arrow key recall).
2938
2947
2939 The following GLOBAL variables always exist (so don't overwrite them!):
2948 The following GLOBAL variables always exist (so don't overwrite them!):
2940 _i: stores previous input. _ii: next previous. _iii: next-next previous.
2949 _i: stores previous input. _ii: next previous. _iii: next-next previous.
2941 _ih : a list of all input _ih[n] is the input from line n and this list
2950 _ih : a list of all input _ih[n] is the input from line n and this list
2942 is aliased to the global variable In. If you overwrite In with a
2951 is aliased to the global variable In. If you overwrite In with a
2943 variable of your own, you can remake the assignment to the internal list
2952 variable of your own, you can remake the assignment to the internal list
2944 with a simple 'In=_ih'.
2953 with a simple 'In=_ih'.
2945
2954
2946 Additionally, global variables named _i<n> are dynamically created (<n>
2955 Additionally, global variables named _i<n> are dynamically created (<n>
2947 being the prompt counter), such that
2956 being the prompt counter), such that
2948 _i<n> == _ih[<n>] == In[<n>].
2957 _i<n> == _ih[<n>] == In[<n>].
2949
2958
2950 For example, what you typed at prompt 14 is available as _i14, _ih[14]
2959 For example, what you typed at prompt 14 is available as _i14, _ih[14]
2951 and In[14].
2960 and In[14].
2952
2961
2953 This allows you to easily cut and paste multi line interactive prompts
2962 This allows you to easily cut and paste multi line interactive prompts
2954 by printing them out: they print like a clean string, without prompt
2963 by printing them out: they print like a clean string, without prompt
2955 characters. You can also manipulate them like regular variables (they
2964 characters. You can also manipulate them like regular variables (they
2956 are strings), modify or exec them (typing 'exec _i9' will re-execute the
2965 are strings), modify or exec them (typing 'exec _i9' will re-execute the
2957 contents of input prompt 9, 'exec In[9:14]+In[18]' will re-execute lines
2966 contents of input prompt 9, 'exec In[9:14]+In[18]' will re-execute lines
2958 9 through 13 and line 18).
2967 9 through 13 and line 18).
2959
2968
2960 You can also re-execute multiple lines of input easily by using the
2969 You can also re-execute multiple lines of input easily by using the
2961 magic %macro function (which automates the process and allows
2970 magic %macro function (which automates the process and allows
2962 re-execution without having to type 'exec' every time). The macro system
2971 re-execution without having to type 'exec' every time). The macro system
2963 also allows you to re-execute previous lines which include magic
2972 also allows you to re-execute previous lines which include magic
2964 function calls (which require special processing). Type %macro? or see
2973 function calls (which require special processing). Type %macro? or see
2965 sec. 6.2 <#sec:magic> for more details on the macro system.
2974 sec. 6.2 <#sec:magic> for more details on the macro system.
2966
2975
2967 A history function %hist allows you to see any part of your input
2976 A history function %hist allows you to see any part of your input
2968 history by printing a range of the _i variables.
2977 history by printing a range of the _i variables.
2969
2978
2970 Output caching system
2979 Output caching system
2971 ---------------------
2980 ---------------------
2972
2981
2973 For output that is returned from actions, a system similar to the input
2982 For output that is returned from actions, a system similar to the input
2974 cache exists but using _ instead of _i. Only actions that produce a
2983 cache exists but using _ instead of _i. Only actions that produce a
2975 result (NOT assignments, for example) are cached. If you are familiar
2984 result (NOT assignments, for example) are cached. If you are familiar
2976 with Mathematica, IPython's _ variables behave exactly like
2985 with Mathematica, IPython's _ variables behave exactly like
2977 Mathematica's % variables.
2986 Mathematica's % variables.
2978
2987
2979 The following GLOBAL variables always exist (so don't overwrite them!):
2988 The following GLOBAL variables always exist (so don't overwrite them!):
2980
2989
2981 * [_] (a single underscore) : stores previous output, like Python's
2990 * [_] (a single underscore) : stores previous output, like Python's
2982 default interpreter.
2991 default interpreter.
2983 * [__] (two underscores): next previous.
2992 * [__] (two underscores): next previous.
2984 * [___] (three underscores): next-next previous.
2993 * [___] (three underscores): next-next previous.
2985
2994
2986 Additionally, global variables named _<n> are dynamically created (<n>
2995 Additionally, global variables named _<n> are dynamically created (<n>
2987 being the prompt counter), such that the result of output <n> is always
2996 being the prompt counter), such that the result of output <n> is always
2988 available as _<n> (don't use the angle brackets, just the number, e.g.
2997 available as _<n> (don't use the angle brackets, just the number, e.g.
2989 _21).
2998 _21).
2990
2999
2991 These global variables are all stored in a global dictionary (not a
3000 These global variables are all stored in a global dictionary (not a
2992 list, since it only has entries for lines which returned a result)
3001 list, since it only has entries for lines which returned a result)
2993 available under the names _oh and Out (similar to _ih and In). So the
3002 available under the names _oh and Out (similar to _ih and In). So the
2994 output from line 12 can be obtained as _12, Out[12] or _oh[12]. If you
3003 output from line 12 can be obtained as _12, Out[12] or _oh[12]. If you
2995 accidentally overwrite the Out variable you can recover it by typing
3004 accidentally overwrite the Out variable you can recover it by typing
2996 'Out=_oh' at the prompt.
3005 'Out=_oh' at the prompt.
2997
3006
2998 This system obviously can potentially put heavy memory demands on your
3007 This system obviously can potentially put heavy memory demands on your
2999 system, since it prevents Python's garbage collector from removing any
3008 system, since it prevents Python's garbage collector from removing any
3000 previously computed results. You can control how many results are kept
3009 previously computed results. You can control how many results are kept
3001 in memory with the option (at the command line or in your ipythonrc
3010 in memory with the option (at the command line or in your ipythonrc
3002 file) cache_size. If you set it to 0, the whole system is completely
3011 file) cache_size. If you set it to 0, the whole system is completely
3003 disabled and the prompts revert to the classic '>>>' of normal Python.
3012 disabled and the prompts revert to the classic '>>>' of normal Python.
3004
3013
3005
3014
3006 Directory history
3015 Directory history
3007 -----------------
3016 -----------------
3008
3017
3009 Your history of visited directories is kept in the global list _dh, and
3018 Your history of visited directories is kept in the global list _dh, and
3010 the magic %cd command can be used to go to any entry in that list. The
3019 the magic %cd command can be used to go to any entry in that list. The
3011 %dhist command allows you to view this history.
3020 %dhist command allows you to view this history. do ``cd -<TAB`` to
3021 conventiently view the directory history.
3012
3022
3013
3023
3014 Automatic parentheses and quotes
3024 Automatic parentheses and quotes
3015 --------------------------------
3025 --------------------------------
3016
3026
3017 These features were adapted from Nathan Gray's LazyPython. They are
3027 These features were adapted from Nathan Gray's LazyPython. They are
3018 meant to allow less typing for common situations.
3028 meant to allow less typing for common situations.
3019
3029
3020
3030
3021 Automatic parentheses
3031 Automatic parentheses
3022 ---------------------
3032 ---------------------
3023
3033
3024 Callable objects (i.e. functions, methods, etc) can be invoked like this
3034 Callable objects (i.e. functions, methods, etc) can be invoked like this
3025 (notice the commas between the arguments)::
3035 (notice the commas between the arguments)::
3026
3036
3027 >>> callable_ob arg1, arg2, arg3
3037 >>> callable_ob arg1, arg2, arg3
3028
3038
3029 and the input will be translated to this::
3039 and the input will be translated to this::
3030
3040
3031 -> callable_ob(arg1, arg2, arg3)
3041 -> callable_ob(arg1, arg2, arg3)
3032
3042
3033 You can force automatic parentheses by using '/' as the first character
3043 You can force automatic parentheses by using '/' as the first character
3034 of a line. For example::
3044 of a line. For example::
3035
3045
3036 >>> /globals # becomes 'globals()'
3046 >>> /globals # becomes 'globals()'
3037
3047
3038 Note that the '/' MUST be the first character on the line! This won't work::
3048 Note that the '/' MUST be the first character on the line! This won't work::
3039
3049
3040 >>> print /globals # syntax error
3050 >>> print /globals # syntax error
3041
3051
3042 In most cases the automatic algorithm should work, so you should rarely
3052 In most cases the automatic algorithm should work, so you should rarely
3043 need to explicitly invoke /. One notable exception is if you are trying
3053 need to explicitly invoke /. One notable exception is if you are trying
3044 to call a function with a list of tuples as arguments (the parenthesis
3054 to call a function with a list of tuples as arguments (the parenthesis
3045 will confuse IPython)::
3055 will confuse IPython)::
3046
3056
3047 In [1]: zip (1,2,3),(4,5,6) # won't work
3057 In [1]: zip (1,2,3),(4,5,6) # won't work
3048
3058
3049 but this will work::
3059 but this will work::
3050
3060
3051 In [2]: /zip (1,2,3),(4,5,6)
3061 In [2]: /zip (1,2,3),(4,5,6)
3052 ---> zip ((1,2,3),(4,5,6))
3062 ---> zip ((1,2,3),(4,5,6))
3053 Out[2]= [(1, 4), (2, 5), (3, 6)]
3063 Out[2]= [(1, 4), (2, 5), (3, 6)]
3054
3064
3055 IPython tells you that it has altered your command line by displaying
3065 IPython tells you that it has altered your command line by displaying
3056 the new command line preceded by ->. e.g.::
3066 the new command line preceded by ->. e.g.::
3057
3067
3058 In [18]: callable list
3068 In [18]: callable list
3059 ----> callable (list)
3069 ----> callable (list)
3060
3070
3061
3071
3062 Automatic quoting
3072 Automatic quoting
3063 -----------------
3073 -----------------
3064
3074
3065 You can force automatic quoting of a function's arguments by using ','
3075 You can force automatic quoting of a function's arguments by using ','
3066 or ';' as the first character of a line. For example::
3076 or ';' as the first character of a line. For example::
3067
3077
3068 >>> ,my_function /home/me # becomes my_function("/home/me")
3078 >>> ,my_function /home/me # becomes my_function("/home/me")
3069
3079
3070 If you use ';' instead, the whole argument is quoted as a single string
3080 If you use ';' instead, the whole argument is quoted as a single string
3071 (while ',' splits on whitespace)::
3081 (while ',' splits on whitespace)::
3072
3082
3073 >>> ,my_function a b c # becomes my_function("a","b","c")
3083 >>> ,my_function a b c # becomes my_function("a","b","c")
3074
3084
3075 >>> ;my_function a b c # becomes my_function("a b c")
3085 >>> ;my_function a b c # becomes my_function("a b c")
3076
3086
3077 Note that the ',' or ';' MUST be the first character on the line! This
3087 Note that the ',' or ';' MUST be the first character on the line! This
3078 won't work::
3088 won't work::
3079
3089
3080 >>> x = ,my_function /home/me # syntax error
3090 >>> x = ,my_function /home/me # syntax error
3081
3091
3082 Customization
3092 Customization
3083 =============
3093 =============
3084
3094
3085 As we've already mentioned, IPython reads a configuration file which can
3095 As we've already mentioned, IPython reads a configuration file which can
3086 be specified at the command line (-rcfile) or which by default is
3096 be specified at the command line (-rcfile) or which by default is
3087 assumed to be called ipythonrc. Such a file is looked for in the current
3097 assumed to be called ipythonrc. Such a file is looked for in the current
3088 directory where IPython is started and then in your IPYTHONDIR, which
3098 directory where IPython is started and then in your IPYTHONDIR, which
3089 allows you to have local configuration files for specific projects. In
3099 allows you to have local configuration files for specific projects. In
3090 this section we will call these types of configuration files simply
3100 this section we will call these types of configuration files simply
3091 rcfiles (short for resource configuration file).
3101 rcfiles (short for resource configuration file).
3092
3102
3093 The syntax of an rcfile is one of key-value pairs separated by
3103 The syntax of an rcfile is one of key-value pairs separated by
3094 whitespace, one per line. Lines beginning with a # are ignored as
3104 whitespace, one per line. Lines beginning with a # are ignored as
3095 comments, but comments can not be put on lines with data (the parser is
3105 comments, but comments can not be put on lines with data (the parser is
3096 fairly primitive). Note that these are not python files, and this is
3106 fairly primitive). Note that these are not python files, and this is
3097 deliberate, because it allows us to do some things which would be quite
3107 deliberate, because it allows us to do some things which would be quite
3098 tricky to implement if they were normal python files.
3108 tricky to implement if they were normal python files.
3099
3109
3100 First, an rcfile can contain permanent default values for almost all
3110 First, an rcfile can contain permanent default values for almost all
3101 command line options (except things like -help or -Version). Sec 5.2
3111 command line options (except things like -help or -Version). Sec 5.2
3102 <node5.html#sec:cmd-line-opts> contains a description of all
3112 <node5.html#sec:cmd-line-opts> contains a description of all
3103 command-line options. However, values you explicitly specify at the
3113 command-line options. However, values you explicitly specify at the
3104 command line override the values defined in the rcfile.
3114 command line override the values defined in the rcfile.
3105
3115
3106 Besides command line option values, the rcfile can specify values for
3116 Besides command line option values, the rcfile can specify values for
3107 certain extra special options which are not available at the command
3117 certain extra special options which are not available at the command
3108 line. These options are briefly described below.
3118 line. These options are briefly described below.
3109
3119
3110 Each of these options may appear as many times as you need it in the file.
3120 Each of these options may appear as many times as you need it in the file.
3111
3121
3112 * [include <file1> <file2> ...:] you can name other rcfiles you want
3122 * [include <file1> <file2> ...:] you can name other rcfiles you want
3113 to recursively load up to 15 levels (don't use the <> brackets in
3123 to recursively load up to 15 levels (don't use the <> brackets in
3114 your names!). This feature allows you to define a 'base' rcfile
3124 your names!). This feature allows you to define a 'base' rcfile
3115 with general options and special-purpose files which can be loaded
3125 with general options and special-purpose files which can be loaded
3116 only when needed with particular configuration options. To make
3126 only when needed with particular configuration options. To make
3117 this more convenient, IPython accepts the -profile <name> option
3127 this more convenient, IPython accepts the -profile <name> option
3118 (abbreviates to -p <name>) which tells it to look for an rcfile
3128 (abbreviates to -p <name>) which tells it to look for an rcfile
3119 named ipythonrc-<name>.
3129 named ipythonrc-<name>.
3120 * [import_mod <mod1> <mod2> ...:] import modules with 'import
3130 * [import_mod <mod1> <mod2> ...:] import modules with 'import
3121 <mod1>,<mod2>,...'
3131 <mod1>,<mod2>,...'
3122 * [import_some <mod> <f1> <f2> ...:] import functions with 'from
3132 * [import_some <mod> <f1> <f2> ...:] import functions with 'from
3123 <mod> import <f1>,<f2>,...'
3133 <mod> import <f1>,<f2>,...'
3124 * [import_all <mod1> <mod2> ...:] for each module listed import
3134 * [import_all <mod1> <mod2> ...:] for each module listed import
3125 functions with ``from <mod> import *``.
3135 functions with ``from <mod> import *``.
3126 * [execute <python code>:] give any single-line python code to be
3136 * [execute <python code>:] give any single-line python code to be
3127 executed.
3137 executed.
3128 * [execfile <filename>:] execute the python file given with an
3138 * [execfile <filename>:] execute the python file given with an
3129 'execfile(filename)' command. Username expansion is performed on
3139 'execfile(filename)' command. Username expansion is performed on
3130 the given names. So if you need any amount of extra fancy
3140 the given names. So if you need any amount of extra fancy
3131 customization that won't fit in any of the above 'canned' options,
3141 customization that won't fit in any of the above 'canned' options,
3132 you can just put it in a separate python file and execute it.
3142 you can just put it in a separate python file and execute it.
3133 * [alias <alias_def>:] this is equivalent to calling
3143 * [alias <alias_def>:] this is equivalent to calling
3134 '%alias <alias_def>' at the IPython command line. This way, from
3144 '%alias <alias_def>' at the IPython command line. This way, from
3135 within IPython you can do common system tasks without having to
3145 within IPython you can do common system tasks without having to
3136 exit it or use the ! escape. IPython isn't meant to be a shell
3146 exit it or use the ! escape. IPython isn't meant to be a shell
3137 replacement, but it is often very useful to be able to do things
3147 replacement, but it is often very useful to be able to do things
3138 with files while testing code. This gives you the flexibility to
3148 with files while testing code. This gives you the flexibility to
3139 have within IPython any aliases you may be used to under your
3149 have within IPython any aliases you may be used to under your
3140 normal system shell.
3150 normal system shell.
3141
3151
3142
3152
3143
3153
3144 Sample ipythonrc file
3154 Sample ipythonrc file
3145 ---------------------
3155 ---------------------
3146
3156
3147 The default rcfile, called ipythonrc and supplied in your IPYTHONDIR
3157 The default rcfile, called ipythonrc and supplied in your IPYTHONDIR
3148 directory contains lots of comments on all of these options. We
3158 directory contains lots of comments on all of these options. We
3149 reproduce it here for reference::
3159 reproduce it here for reference::
3150
3160
3151
3161
3152 # -*- Mode: Shell-Script -*- Not really, but shows comments correctly
3162 # -*- Mode: Shell-Script -*- Not really, but shows comments correctly
3153 # $Id: ipythonrc 2156 2007-03-19 02:32:19Z fperez $
3163 # $Id: ipythonrc 2156 2007-03-19 02:32:19Z fperez $
3154
3164
3155 #***************************************************************************
3165 #***************************************************************************
3156 #
3166 #
3157 # Configuration file for IPython -- ipythonrc format
3167 # Configuration file for IPython -- ipythonrc format
3158 #
3168 #
3159 # ===========================================================
3169 # ===========================================================
3160 # Deprecation note: you should look into modifying ipy_user_conf.py (located
3170 # Deprecation note: you should look into modifying ipy_user_conf.py (located
3161 # in ~/.ipython or ~/_ipython, depending on your platform) instead, it's a
3171 # in ~/.ipython or ~/_ipython, depending on your platform) instead, it's a
3162 # more flexible and robust (and better supported!) configuration
3172 # more flexible and robust (and better supported!) configuration
3163 # method.
3173 # method.
3164 # ===========================================================
3174 # ===========================================================
3165 #
3175 #
3166 # The format of this file is simply one of 'key value' lines.
3176 # The format of this file is simply one of 'key value' lines.
3167 # Lines containing only whitespace at the beginning and then a # are ignored
3177 # Lines containing only whitespace at the beginning and then a # are ignored
3168 # as comments. But comments can NOT be put on lines with data.
3178 # as comments. But comments can NOT be put on lines with data.
3169
3179
3170 # The meaning and use of each key are explained below.
3180 # The meaning and use of each key are explained below.
3171
3181
3172 #---------------------------------------------------------------------------
3182 #---------------------------------------------------------------------------
3173 # Section: included files
3183 # Section: included files
3174
3184
3175 # Put one or more *config* files (with the syntax of this file) you want to
3185 # Put one or more *config* files (with the syntax of this file) you want to
3176 # include. For keys with a unique value the outermost file has precedence. For
3186 # include. For keys with a unique value the outermost file has precedence. For
3177 # keys with multiple values, they all get assembled into a list which then
3187 # keys with multiple values, they all get assembled into a list which then
3178 # gets loaded by IPython.
3188 # gets loaded by IPython.
3179
3189
3180 # In this file, all lists of things should simply be space-separated.
3190 # In this file, all lists of things should simply be space-separated.
3181
3191
3182 # This allows you to build hierarchies of files which recursively load
3192 # This allows you to build hierarchies of files which recursively load
3183 # lower-level services. If this is your main ~/.ipython/ipythonrc file, you
3193 # lower-level services. If this is your main ~/.ipython/ipythonrc file, you
3184 # should only keep here basic things you always want available. Then you can
3194 # should only keep here basic things you always want available. Then you can
3185 # include it in every other special-purpose config file you create.
3195 # include it in every other special-purpose config file you create.
3186 include
3196 include
3187
3197
3188 #---------------------------------------------------------------------------
3198 #---------------------------------------------------------------------------
3189 # Section: startup setup
3199 # Section: startup setup
3190
3200
3191 # These are mostly things which parallel a command line option of the same
3201 # These are mostly things which parallel a command line option of the same
3192 # name.
3202 # name.
3193
3203
3194 # Keys in this section should only appear once. If any key from this section
3204 # Keys in this section should only appear once. If any key from this section
3195 # is encountered more than once, the last value remains, all earlier ones get
3205 # is encountered more than once, the last value remains, all earlier ones get
3196 # discarded.
3206 # discarded.
3197
3207
3198
3208
3199 # Automatic calling of callable objects. If set to 1 or 2, callable objects
3209 # Automatic calling of callable objects. If set to 1 or 2, callable objects
3200 # are automatically called when invoked at the command line, even if you don't
3210 # are automatically called when invoked at the command line, even if you don't
3201 # type parentheses. IPython adds the parentheses for you. For example:
3211 # type parentheses. IPython adds the parentheses for you. For example:
3202
3212
3203 #In [1]: str 45
3213 #In [1]: str 45
3204 #------> str(45)
3214 #------> str(45)
3205 #Out[1]: '45'
3215 #Out[1]: '45'
3206
3216
3207 # IPython reprints your line with '---->' indicating that it added
3217 # IPython reprints your line with '---->' indicating that it added
3208 # parentheses. While this option is very convenient for interactive use, it
3218 # parentheses. While this option is very convenient for interactive use, it
3209 # may occasionally cause problems with objects which have side-effects if
3219 # may occasionally cause problems with objects which have side-effects if
3210 # called unexpectedly.
3220 # called unexpectedly.
3211
3221
3212 # The valid values for autocall are:
3222 # The valid values for autocall are:
3213
3223
3214 # autocall 0 -> disabled (you can toggle it at runtime with the %autocall magic)
3224 # autocall 0 -> disabled (you can toggle it at runtime with the %autocall magic)
3215
3225
3216 # autocall 1 -> active, but do not apply if there are no arguments on the line.
3226 # autocall 1 -> active, but do not apply if there are no arguments on the line.
3217
3227
3218 # In this mode, you get:
3228 # In this mode, you get:
3219
3229
3220 #In [1]: callable
3230 #In [1]: callable
3221 #Out[1]: <built-in function callable>
3231 #Out[1]: <built-in function callable>
3222
3232
3223 #In [2]: callable 'hello'
3233 #In [2]: callable 'hello'
3224 #------> callable('hello')
3234 #------> callable('hello')
3225 #Out[2]: False
3235 #Out[2]: False
3226
3236
3227 # 2 -> Active always. Even if no arguments are present, the callable object
3237 # 2 -> Active always. Even if no arguments are present, the callable object
3228 # is called:
3238 # is called:
3229
3239
3230 #In [4]: callable
3240 #In [4]: callable
3231 #------> callable()
3241 #------> callable()
3232
3242
3233 # Note that even with autocall off, you can still use '/' at the start of a
3243 # Note that even with autocall off, you can still use '/' at the start of a
3234 # line to treat the first argument on the command line as a function and add
3244 # line to treat the first argument on the command line as a function and add
3235 # parentheses to it:
3245 # parentheses to it:
3236
3246
3237 #In [8]: /str 43
3247 #In [8]: /str 43
3238 #------> str(43)
3248 #------> str(43)
3239 #Out[8]: '43'
3249 #Out[8]: '43'
3240
3250
3241 autocall 1
3251 autocall 1
3242
3252
3243 # Auto-edit syntax errors. When you use the %edit magic in ipython to edit
3253 # Auto-edit syntax errors. When you use the %edit magic in ipython to edit
3244 # source code (see the 'editor' variable below), it is possible that you save
3254 # source code (see the 'editor' variable below), it is possible that you save
3245 # a file with syntax errors in it. If this variable is true, IPython will ask
3255 # a file with syntax errors in it. If this variable is true, IPython will ask
3246 # you whether to re-open the editor immediately to correct such an error.
3256 # you whether to re-open the editor immediately to correct such an error.
3247
3257
3248 autoedit_syntax 0
3258 autoedit_syntax 0
3249
3259
3250 # Auto-indent. IPython can recognize lines ending in ':' and indent the next
3260 # Auto-indent. IPython can recognize lines ending in ':' and indent the next
3251 # line, while also un-indenting automatically after 'raise' or 'return'.
3261 # line, while also un-indenting automatically after 'raise' or 'return'.
3252
3262
3253 # This feature uses the readline library, so it will honor your ~/.inputrc
3263 # This feature uses the readline library, so it will honor your ~/.inputrc
3254 # configuration (or whatever file your INPUTRC variable points to). Adding
3264 # configuration (or whatever file your INPUTRC variable points to). Adding
3255 # the following lines to your .inputrc file can make indent/unindenting more
3265 # the following lines to your .inputrc file can make indent/unindenting more
3256 # convenient (M-i indents, M-u unindents):
3266 # convenient (M-i indents, M-u unindents):
3257
3267
3258 # $if Python
3268 # $if Python
3259 # "\M-i": " "
3269 # "\M-i": " "
3260 # "\M-u": "\d\d\d\d"
3270 # "\M-u": "\d\d\d\d"
3261 # $endif
3271 # $endif
3262
3272
3263 # The feature is potentially a bit dangerous, because it can cause problems
3273 # The feature is potentially a bit dangerous, because it can cause problems
3264 # with pasting of indented code (the pasted code gets re-indented on each
3274 # with pasting of indented code (the pasted code gets re-indented on each
3265 # line). But it's a huge time-saver when working interactively. The magic
3275 # line). But it's a huge time-saver when working interactively. The magic
3266 # function %autoindent allows you to toggle it on/off at runtime.
3276 # function %autoindent allows you to toggle it on/off at runtime.
3267
3277
3268 autoindent 1
3278 autoindent 1
3269
3279
3270 # Auto-magic. This gives you access to all the magic functions without having
3280 # Auto-magic. This gives you access to all the magic functions without having
3271 # to prepend them with an % sign. If you define a variable with the same name
3281 # to prepend them with an % sign. If you define a variable with the same name
3272 # as a magic function (say who=1), you will need to access the magic function
3282 # as a magic function (say who=1), you will need to access the magic function
3273 # with % (%who in this example). However, if later you delete your variable
3283 # with % (%who in this example). However, if later you delete your variable
3274 # (del who), you'll recover the automagic calling form.
3284 # (del who), you'll recover the automagic calling form.
3275
3285
3276 # Considering that many magic functions provide a lot of shell-like
3286 # Considering that many magic functions provide a lot of shell-like
3277 # functionality, automagic gives you something close to a full Python+system
3287 # functionality, automagic gives you something close to a full Python+system
3278 # shell environment (and you can extend it further if you want).
3288 # shell environment (and you can extend it further if you want).
3279
3289
3280 automagic 1
3290 automagic 1
3281
3291
3282 # Size of the output cache. After this many entries are stored, the cache will
3292 # Size of the output cache. After this many entries are stored, the cache will
3283 # get flushed. Depending on the size of your intermediate calculations, you
3293 # get flushed. Depending on the size of your intermediate calculations, you
3284 # may have memory problems if you make it too big, since keeping things in the
3294 # may have memory problems if you make it too big, since keeping things in the
3285 # cache prevents Python from reclaiming the memory for old results. Experiment
3295 # cache prevents Python from reclaiming the memory for old results. Experiment
3286 # with a value that works well for you.
3296 # with a value that works well for you.
3287
3297
3288 # If you choose cache_size 0 IPython will revert to python's regular >>>
3298 # If you choose cache_size 0 IPython will revert to python's regular >>>
3289 # unnumbered prompt. You will still have _, __ and ___ for your last three
3299 # unnumbered prompt. You will still have _, __ and ___ for your last three
3290 # results, but that will be it. No dynamic _1, _2, etc. will be created. If
3300 # results, but that will be it. No dynamic _1, _2, etc. will be created. If
3291 # you are running on a slow machine or with very limited memory, this may
3301 # you are running on a slow machine or with very limited memory, this may
3292 # help.
3302 # help.
3293
3303
3294 cache_size 1000
3304 cache_size 1000
3295
3305
3296 # Classic mode: Setting 'classic 1' you lose many of IPython niceties,
3306 # Classic mode: Setting 'classic 1' you lose many of IPython niceties,
3297 # but that's your choice! Classic 1 -> same as IPython -classic.
3307 # but that's your choice! Classic 1 -> same as IPython -classic.
3298 # Note that this is _not_ the normal python interpreter, it's simply
3308 # Note that this is _not_ the normal python interpreter, it's simply
3299 # IPython emulating most of the classic interpreter's behavior.
3309 # IPython emulating most of the classic interpreter's behavior.
3300 classic 0
3310 classic 0
3301
3311
3302 # colors - Coloring option for prompts and traceback printouts.
3312 # colors - Coloring option for prompts and traceback printouts.
3303
3313
3304 # Currently available schemes: NoColor, Linux, LightBG.
3314 # Currently available schemes: NoColor, Linux, LightBG.
3305
3315
3306 # This option allows coloring the prompts and traceback printouts. This
3316 # This option allows coloring the prompts and traceback printouts. This
3307 # requires a terminal which can properly handle color escape sequences. If you
3317 # requires a terminal which can properly handle color escape sequences. If you
3308 # are having problems with this, use the NoColor scheme (uses no color escapes
3318 # are having problems with this, use the NoColor scheme (uses no color escapes
3309 # at all).
3319 # at all).
3310
3320
3311 # The Linux option works well in linux console type environments: dark
3321 # The Linux option works well in linux console type environments: dark
3312 # background with light fonts.
3322 # background with light fonts.
3313
3323
3314 # LightBG is similar to Linux but swaps dark/light colors to be more readable
3324 # LightBG is similar to Linux but swaps dark/light colors to be more readable
3315 # in light background terminals.
3325 # in light background terminals.
3316
3326
3317 # keep uncommented only the one you want:
3327 # keep uncommented only the one you want:
3318 colors Linux
3328 colors Linux
3319 #colors LightBG
3329 #colors LightBG
3320 #colors NoColor
3330 #colors NoColor
3321
3331
3322 ########################
3332 ########################
3323 # Note to Windows users
3333 # Note to Windows users
3324 #
3334 #
3325 # Color and readline support is avaialble to Windows users via Gary Bishop's
3335 # Color and readline support is avaialble to Windows users via Gary Bishop's
3326 # readline library. You can find Gary's tools at
3336 # readline library. You can find Gary's tools at
3327 # http://sourceforge.net/projects/uncpythontools.
3337 # http://sourceforge.net/projects/uncpythontools.
3328 # Note that his readline module requires in turn the ctypes library, available
3338 # Note that his readline module requires in turn the ctypes library, available
3329 # at http://starship.python.net/crew/theller/ctypes.
3339 # at http://starship.python.net/crew/theller/ctypes.
3330 ########################
3340 ########################
3331
3341
3332 # color_info: IPython can display information about objects via a set of
3342 # color_info: IPython can display information about objects via a set of
3333 # functions, and optionally can use colors for this, syntax highlighting
3343 # functions, and optionally can use colors for this, syntax highlighting
3334 # source code and various other elements. This information is passed through a
3344 # source code and various other elements. This information is passed through a
3335 # pager (it defaults to 'less' if $PAGER is not set).
3345 # pager (it defaults to 'less' if $PAGER is not set).
3336
3346
3337 # If your pager has problems, try to setting it to properly handle escapes
3347 # If your pager has problems, try to setting it to properly handle escapes
3338 # (see the less manpage for detail), or disable this option. The magic
3348 # (see the less manpage for detail), or disable this option. The magic
3339 # function %color_info allows you to toggle this interactively for testing.
3349 # function %color_info allows you to toggle this interactively for testing.
3340
3350
3341 color_info 1
3351 color_info 1
3342
3352
3343 # confirm_exit: set to 1 if you want IPython to confirm when you try to exit
3353 # confirm_exit: set to 1 if you want IPython to confirm when you try to exit
3344 # with an EOF (Control-d in Unix, Control-Z/Enter in Windows). Note that using
3354 # with an EOF (Control-d in Unix, Control-Z/Enter in Windows). Note that using
3345 # the magic functions %Exit or %Quit you can force a direct exit, bypassing
3355 # the magic functions %Exit or %Quit you can force a direct exit, bypassing
3346 # any confirmation.
3356 # any confirmation.
3347
3357
3348 confirm_exit 1
3358 confirm_exit 1
3349
3359
3350 # Use deep_reload() as a substitute for reload() by default. deep_reload() is
3360 # Use deep_reload() as a substitute for reload() by default. deep_reload() is
3351 # still available as dreload() and appears as a builtin.
3361 # still available as dreload() and appears as a builtin.
3352
3362
3353 deep_reload 0
3363 deep_reload 0
3354
3364
3355 # Which editor to use with the %edit command. If you leave this at 0, IPython
3365 # Which editor to use with the %edit command. If you leave this at 0, IPython
3356 # will honor your EDITOR environment variable. Since this editor is invoked on
3366 # will honor your EDITOR environment variable. Since this editor is invoked on
3357 # the fly by ipython and is meant for editing small code snippets, you may
3367 # the fly by ipython and is meant for editing small code snippets, you may
3358 # want to use a small, lightweight editor here.
3368 # want to use a small, lightweight editor here.
3359
3369
3360 # For Emacs users, setting up your Emacs server properly as described in the
3370 # For Emacs users, setting up your Emacs server properly as described in the
3361 # manual is a good idea. An alternative is to use jed, a very light editor
3371 # manual is a good idea. An alternative is to use jed, a very light editor
3362 # with much of the feel of Emacs (though not as powerful for heavy-duty work).
3372 # with much of the feel of Emacs (though not as powerful for heavy-duty work).
3363
3373
3364 editor 0
3374 editor 0
3365
3375
3366 # log 1 -> same as ipython -log. This automatically logs to ./ipython.log
3376 # log 1 -> same as ipython -log. This automatically logs to ./ipython.log
3367 log 0
3377 log 0
3368
3378
3369 # Same as ipython -Logfile YourLogfileName.
3379 # Same as ipython -Logfile YourLogfileName.
3370 # Don't use with log 1 (use one or the other)
3380 # Don't use with log 1 (use one or the other)
3371 logfile ''
3381 logfile ''
3372
3382
3373 # banner 0 -> same as ipython -nobanner
3383 # banner 0 -> same as ipython -nobanner
3374 banner 1
3384 banner 1
3375
3385
3376 # messages 0 -> same as ipython -nomessages
3386 # messages 0 -> same as ipython -nomessages
3377 messages 1
3387 messages 1
3378
3388
3379 # Automatically call the pdb debugger after every uncaught exception. If you
3389 # Automatically call the pdb debugger after every uncaught exception. If you
3380 # are used to debugging using pdb, this puts you automatically inside of it
3390 # are used to debugging using pdb, this puts you automatically inside of it
3381 # after any call (either in IPython or in code called by it) which triggers an
3391 # after any call (either in IPython or in code called by it) which triggers an
3382 # exception which goes uncaught.
3392 # exception which goes uncaught.
3383 pdb 0
3393 pdb 0
3384
3394
3385 # Enable the pprint module for printing. pprint tends to give a more readable
3395 # Enable the pprint module for printing. pprint tends to give a more readable
3386 # display (than print) for complex nested data structures.
3396 # display (than print) for complex nested data structures.
3387 pprint 1
3397 pprint 1
3388
3398
3389 # Prompt strings
3399 # Prompt strings
3390
3400
3391 # Most bash-like escapes can be used to customize IPython's prompts, as well as
3401 # Most bash-like escapes can be used to customize IPython's prompts, as well as
3392 # a few additional ones which are IPython-specific. All valid prompt escapes
3402 # a few additional ones which are IPython-specific. All valid prompt escapes
3393 # are described in detail in the Customization section of the IPython HTML/PDF
3403 # are described in detail in the Customization section of the IPython HTML/PDF
3394 # manual.
3404 # manual.
3395
3405
3396 # Use \# to represent the current prompt number, and quote them to protect
3406 # Use \# to represent the current prompt number, and quote them to protect
3397 # spaces.
3407 # spaces.
3398 prompt_in1 'In [\#]: '
3408 prompt_in1 'In [\#]: '
3399
3409
3400 # \D is replaced by as many dots as there are digits in the
3410 # \D is replaced by as many dots as there are digits in the
3401 # current value of \#.
3411 # current value of \#.
3402 prompt_in2 ' .\D.: '
3412 prompt_in2 ' .\D.: '
3403
3413
3404 prompt_out 'Out[\#]: '
3414 prompt_out 'Out[\#]: '
3405
3415
3406 # Select whether to left-pad the output prompts to match the length of the
3416 # Select whether to left-pad the output prompts to match the length of the
3407 # input ones. This allows you for example to use a simple '>' as an output
3417 # input ones. This allows you for example to use a simple '>' as an output
3408 # prompt, and yet have the output line up with the input. If set to false,
3418 # prompt, and yet have the output line up with the input. If set to false,
3409 # the output prompts will be unpadded (flush left).
3419 # the output prompts will be unpadded (flush left).
3410 prompts_pad_left 1
3420 prompts_pad_left 1
3411
3421
3412 # Pylab support: when ipython is started with the -pylab switch, by default it
3422 # Pylab support: when ipython is started with the -pylab switch, by default it
3413 # executes 'from matplotlib.pylab import *'. Set this variable to false if you
3423 # executes 'from matplotlib.pylab import *'. Set this variable to false if you
3414 # want to disable this behavior.
3424 # want to disable this behavior.
3415
3425
3416 # For details on pylab, see the matplotlib website:
3426 # For details on pylab, see the matplotlib website:
3417 # http://matplotlib.sf.net
3427 # http://matplotlib.sf.net
3418 pylab_import_all 1
3428 pylab_import_all 1
3419
3429
3420
3430
3421 # quick 1 -> same as ipython -quick
3431 # quick 1 -> same as ipython -quick
3422 quick 0
3432 quick 0
3423
3433
3424 # Use the readline library (1) or not (0). Most users will want this on, but
3434 # Use the readline library (1) or not (0). Most users will want this on, but
3425 # if you experience strange problems with line management (mainly when using
3435 # if you experience strange problems with line management (mainly when using
3426 # IPython inside Emacs buffers) you may try disabling it. Not having it on
3436 # IPython inside Emacs buffers) you may try disabling it. Not having it on
3427 # prevents you from getting command history with the arrow keys, searching and
3437 # prevents you from getting command history with the arrow keys, searching and
3428 # name completion using TAB.
3438 # name completion using TAB.
3429
3439
3430 readline 1
3440 readline 1
3431
3441
3432 # Screen Length: number of lines of your screen. This is used to control
3442 # Screen Length: number of lines of your screen. This is used to control
3433 # printing of very long strings. Strings longer than this number of lines will
3443 # printing of very long strings. Strings longer than this number of lines will
3434 # be paged with the less command instead of directly printed.
3444 # be paged with the less command instead of directly printed.
3435
3445
3436 # The default value for this is 0, which means IPython will auto-detect your
3446 # The default value for this is 0, which means IPython will auto-detect your
3437 # screen size every time it needs to print. If for some reason this isn't
3447 # screen size every time it needs to print. If for some reason this isn't
3438 # working well (it needs curses support), specify it yourself. Otherwise don't
3448 # working well (it needs curses support), specify it yourself. Otherwise don't
3439 # change the default.
3449 # change the default.
3440
3450
3441 screen_length 0
3451 screen_length 0
3442
3452
3443 # Prompt separators for input and output.
3453 # Prompt separators for input and output.
3444 # Use \n for newline explicitly, without quotes.
3454 # Use \n for newline explicitly, without quotes.
3445 # Use 0 (like at the cmd line) to turn off a given separator.
3455 # Use 0 (like at the cmd line) to turn off a given separator.
3446
3456
3447 # The structure of prompt printing is:
3457 # The structure of prompt printing is:
3448 # (SeparateIn)Input....
3458 # (SeparateIn)Input....
3449 # (SeparateOut)Output...
3459 # (SeparateOut)Output...
3450 # (SeparateOut2), # that is, no newline is printed after Out2
3460 # (SeparateOut2), # that is, no newline is printed after Out2
3451 # By choosing these you can organize your output any way you want.
3461 # By choosing these you can organize your output any way you want.
3452
3462
3453 separate_in \n
3463 separate_in \n
3454 separate_out 0
3464 separate_out 0
3455 separate_out2 0
3465 separate_out2 0
3456
3466
3457 # 'nosep 1' is a shorthand for '-SeparateIn 0 -SeparateOut 0 -SeparateOut2 0'.
3467 # 'nosep 1' is a shorthand for '-SeparateIn 0 -SeparateOut 0 -SeparateOut2 0'.
3458 # Simply removes all input/output separators, overriding the choices above.
3468 # Simply removes all input/output separators, overriding the choices above.
3459 nosep 0
3469 nosep 0
3460
3470
3461 # Wildcard searches - IPython has a system for searching names using
3471 # Wildcard searches - IPython has a system for searching names using
3462 # shell-like wildcards; type %psearch? for details. This variables sets
3472 # shell-like wildcards; type %psearch? for details. This variables sets
3463 # whether by default such searches should be case sensitive or not. You can
3473 # whether by default such searches should be case sensitive or not. You can
3464 # always override the default at the system command line or the IPython
3474 # always override the default at the system command line or the IPython
3465 # prompt.
3475 # prompt.
3466
3476
3467 wildcards_case_sensitive 1
3477 wildcards_case_sensitive 1
3468
3478
3469 # Object information: at what level of detail to display the string form of an
3479 # Object information: at what level of detail to display the string form of an
3470 # object. If set to 0, ipython will compute the string form of any object X,
3480 # object. If set to 0, ipython will compute the string form of any object X,
3471 # by calling str(X), when X? is typed. If set to 1, str(X) will only be
3481 # by calling str(X), when X? is typed. If set to 1, str(X) will only be
3472 # computed when X?? is given, and if set to 2 or higher, it will never be
3482 # computed when X?? is given, and if set to 2 or higher, it will never be
3473 # computed (there is no X??? level of detail). This is mostly of use to
3483 # computed (there is no X??? level of detail). This is mostly of use to
3474 # people who frequently manipulate objects whose string representation is
3484 # people who frequently manipulate objects whose string representation is
3475 # extremely expensive to compute.
3485 # extremely expensive to compute.
3476
3486
3477 object_info_string_level 0
3487 object_info_string_level 0
3478
3488
3479 # xmode - Exception reporting mode.
3489 # xmode - Exception reporting mode.
3480
3490
3481 # Valid modes: Plain, Context and Verbose.
3491 # Valid modes: Plain, Context and Verbose.
3482
3492
3483 # Plain: similar to python's normal traceback printing.
3493 # Plain: similar to python's normal traceback printing.
3484
3494
3485 # Context: prints 5 lines of context source code around each line in the
3495 # Context: prints 5 lines of context source code around each line in the
3486 # traceback.
3496 # traceback.
3487
3497
3488 # Verbose: similar to Context, but additionally prints the variables currently
3498 # Verbose: similar to Context, but additionally prints the variables currently
3489 # visible where the exception happened (shortening their strings if too
3499 # visible where the exception happened (shortening their strings if too
3490 # long). This can potentially be very slow, if you happen to have a huge data
3500 # long). This can potentially be very slow, if you happen to have a huge data
3491 # structure whose string representation is complex to compute. Your computer
3501 # structure whose string representation is complex to compute. Your computer
3492 # may appear to freeze for a while with cpu usage at 100%. If this occurs, you
3502 # may appear to freeze for a while with cpu usage at 100%. If this occurs, you
3493 # can cancel the traceback with Ctrl-C (maybe hitting it more than once).
3503 # can cancel the traceback with Ctrl-C (maybe hitting it more than once).
3494
3504
3495 #xmode Plain
3505 #xmode Plain
3496 xmode Context
3506 xmode Context
3497 #xmode Verbose
3507 #xmode Verbose
3498
3508
3499 # multi_line_specials: if true, allow magics, aliases and shell escapes (via
3509 # multi_line_specials: if true, allow magics, aliases and shell escapes (via
3500 # !cmd) to be used in multi-line input (like for loops). For example, if you
3510 # !cmd) to be used in multi-line input (like for loops). For example, if you
3501 # have this active, the following is valid in IPython:
3511 # have this active, the following is valid in IPython:
3502 #
3512 #
3503 #In [17]: for i in range(3):
3513 #In [17]: for i in range(3):
3504 # ....: mkdir $i
3514 # ....: mkdir $i
3505 # ....: !touch $i/hello
3515 # ....: !touch $i/hello
3506 # ....: ls -l $i
3516 # ....: ls -l $i
3507
3517
3508 multi_line_specials 1
3518 multi_line_specials 1
3509
3519
3510
3520
3511 # System calls: When IPython makes system calls (e.g. via special syntax like
3521 # System calls: When IPython makes system calls (e.g. via special syntax like
3512 # !cmd or !!cmd, or magics like %sc or %sx), it can print the command it is
3522 # !cmd or !!cmd, or magics like %sc or %sx), it can print the command it is
3513 # executing to standard output, prefixed by a header string.
3523 # executing to standard output, prefixed by a header string.
3514
3524
3515 system_header "IPython system call: "
3525 system_header "IPython system call: "
3516
3526
3517 system_verbose 1
3527 system_verbose 1
3518
3528
3519 # wxversion: request a specific wxPython version (used for -wthread)
3529 # wxversion: request a specific wxPython version (used for -wthread)
3520
3530
3521 # Set this to the value of wxPython you want to use, but note that this
3531 # Set this to the value of wxPython you want to use, but note that this
3522 # feature requires you to have the wxversion Python module to work. If you
3532 # feature requires you to have the wxversion Python module to work. If you
3523 # don't have the wxversion module (try 'import wxversion' at the prompt to
3533 # don't have the wxversion module (try 'import wxversion' at the prompt to
3524 # check) or simply want to leave the system to pick up the default, leave this
3534 # check) or simply want to leave the system to pick up the default, leave this
3525 # variable at 0.
3535 # variable at 0.
3526
3536
3527 wxversion 0
3537 wxversion 0
3528
3538
3529 #---------------------------------------------------------------------------
3539 #---------------------------------------------------------------------------
3530 # Section: Readline configuration (readline is not available for MS-Windows)
3540 # Section: Readline configuration (readline is not available for MS-Windows)
3531
3541
3532 # This is done via the following options:
3542 # This is done via the following options:
3533
3543
3534 # (i) readline_parse_and_bind: this option can appear as many times as you
3544 # (i) readline_parse_and_bind: this option can appear as many times as you
3535 # want, each time defining a string to be executed via a
3545 # want, each time defining a string to be executed via a
3536 # readline.parse_and_bind() command. The syntax for valid commands of this
3546 # readline.parse_and_bind() command. The syntax for valid commands of this
3537 # kind can be found by reading the documentation for the GNU readline library,
3547 # kind can be found by reading the documentation for the GNU readline library,
3538 # as these commands are of the kind which readline accepts in its
3548 # as these commands are of the kind which readline accepts in its
3539 # configuration file.
3549 # configuration file.
3540
3550
3541 # The TAB key can be used to complete names at the command line in one of two
3551 # The TAB key can be used to complete names at the command line in one of two
3542 # ways: 'complete' and 'menu-complete'. The difference is that 'complete' only
3552 # ways: 'complete' and 'menu-complete'. The difference is that 'complete' only
3543 # completes as much as possible while 'menu-complete' cycles through all
3553 # completes as much as possible while 'menu-complete' cycles through all
3544 # possible completions. Leave the one you prefer uncommented.
3554 # possible completions. Leave the one you prefer uncommented.
3545
3555
3546 readline_parse_and_bind tab: complete
3556 readline_parse_and_bind tab: complete
3547 #readline_parse_and_bind tab: menu-complete
3557 #readline_parse_and_bind tab: menu-complete
3548
3558
3549 # This binds Control-l to printing the list of all possible completions when
3559 # This binds Control-l to printing the list of all possible completions when
3550 # there is more than one (what 'complete' does when hitting TAB twice, or at
3560 # there is more than one (what 'complete' does when hitting TAB twice, or at
3551 # the first TAB if show-all-if-ambiguous is on)
3561 # the first TAB if show-all-if-ambiguous is on)
3552 readline_parse_and_bind "\C-l": possible-completions
3562 readline_parse_and_bind "\C-l": possible-completions
3553
3563
3554 # This forces readline to automatically print the above list when tab
3564 # This forces readline to automatically print the above list when tab
3555 # completion is set to 'complete'. You can still get this list manually by
3565 # completion is set to 'complete'. You can still get this list manually by
3556 # using the key bound to 'possible-completions' (Control-l by default) or by
3566 # using the key bound to 'possible-completions' (Control-l by default) or by
3557 # hitting TAB twice. Turning this on makes the printing happen at the first
3567 # hitting TAB twice. Turning this on makes the printing happen at the first
3558 # TAB.
3568 # TAB.
3559 readline_parse_and_bind set show-all-if-ambiguous on
3569 readline_parse_and_bind set show-all-if-ambiguous on
3560
3570
3561 # If you have TAB set to complete names, you can rebind any key (Control-o by
3571 # If you have TAB set to complete names, you can rebind any key (Control-o by
3562 # default) to insert a true TAB character.
3572 # default) to insert a true TAB character.
3563 readline_parse_and_bind "\C-o": tab-insert
3573 readline_parse_and_bind "\C-o": tab-insert
3564
3574
3565 # These commands allow you to indent/unindent easily, with the 4-space
3575 # These commands allow you to indent/unindent easily, with the 4-space
3566 # convention of the Python coding standards. Since IPython's internal
3576 # convention of the Python coding standards. Since IPython's internal
3567 # auto-indent system also uses 4 spaces, you should not change the number of
3577 # auto-indent system also uses 4 spaces, you should not change the number of
3568 # spaces in the code below.
3578 # spaces in the code below.
3569 readline_parse_and_bind "\M-i": " "
3579 readline_parse_and_bind "\M-i": " "
3570 readline_parse_and_bind "\M-o": "\d\d\d\d"
3580 readline_parse_and_bind "\M-o": "\d\d\d\d"
3571 readline_parse_and_bind "\M-I": "\d\d\d\d"
3581 readline_parse_and_bind "\M-I": "\d\d\d\d"
3572
3582
3573 # Bindings for incremental searches in the history. These searches use the
3583 # Bindings for incremental searches in the history. These searches use the
3574 # string typed so far on the command line and search anything in the previous
3584 # string typed so far on the command line and search anything in the previous
3575 # input history containing them.
3585 # input history containing them.
3576 readline_parse_and_bind "\C-r": reverse-search-history
3586 readline_parse_and_bind "\C-r": reverse-search-history
3577 readline_parse_and_bind "\C-s": forward-search-history
3587 readline_parse_and_bind "\C-s": forward-search-history
3578
3588
3579 # Bindings for completing the current line in the history of previous
3589 # Bindings for completing the current line in the history of previous
3580 # commands. This allows you to recall any previous command by typing its first
3590 # commands. This allows you to recall any previous command by typing its first
3581 # few letters and hitting Control-p, bypassing all intermediate commands which
3591 # few letters and hitting Control-p, bypassing all intermediate commands which
3582 # may be in the history (much faster than hitting up-arrow 50 times!)
3592 # may be in the history (much faster than hitting up-arrow 50 times!)
3583 readline_parse_and_bind "\C-p": history-search-backward
3593 readline_parse_and_bind "\C-p": history-search-backward
3584 readline_parse_and_bind "\C-n": history-search-forward
3594 readline_parse_and_bind "\C-n": history-search-forward
3585
3595
3586 # I also like to have the same functionality on the plain arrow keys. If you'd
3596 # I also like to have the same functionality on the plain arrow keys. If you'd
3587 # rather have the arrows use all the history (and not just match what you've
3597 # rather have the arrows use all the history (and not just match what you've
3588 # typed so far), comment out or delete the next two lines.
3598 # typed so far), comment out or delete the next two lines.
3589 readline_parse_and_bind "\e[A": history-search-backward
3599 readline_parse_and_bind "\e[A": history-search-backward
3590 readline_parse_and_bind "\e[B": history-search-forward
3600 readline_parse_and_bind "\e[B": history-search-forward
3591
3601
3592 # These are typically on by default under *nix, but not win32.
3602 # These are typically on by default under *nix, but not win32.
3593 readline_parse_and_bind "\C-k": kill-line
3603 readline_parse_and_bind "\C-k": kill-line
3594 readline_parse_and_bind "\C-u": unix-line-discard
3604 readline_parse_and_bind "\C-u": unix-line-discard
3595
3605
3596 # (ii) readline_remove_delims: a string of characters to be removed from the
3606 # (ii) readline_remove_delims: a string of characters to be removed from the
3597 # default word-delimiters list used by readline, so that completions may be
3607 # default word-delimiters list used by readline, so that completions may be
3598 # performed on strings which contain them.
3608 # performed on strings which contain them.
3599
3609
3600 readline_remove_delims -/~
3610 readline_remove_delims -/~
3601
3611
3602 # (iii) readline_merge_completions: whether to merge the result of all
3612 # (iii) readline_merge_completions: whether to merge the result of all
3603 # possible completions or not. If true, IPython will complete filenames,
3613 # possible completions or not. If true, IPython will complete filenames,
3604 # python names and aliases and return all possible completions. If you set it
3614 # python names and aliases and return all possible completions. If you set it
3605 # to false, each completer is used at a time, and only if it doesn't return
3615 # to false, each completer is used at a time, and only if it doesn't return
3606 # any completions is the next one used.
3616 # any completions is the next one used.
3607
3617
3608 # The default order is: [python_matches, file_matches, alias_matches]
3618 # The default order is: [python_matches, file_matches, alias_matches]
3609
3619
3610 readline_merge_completions 1
3620 readline_merge_completions 1
3611
3621
3612 # (iv) readline_omit__names: normally hitting <tab> after a '.' in a name
3622 # (iv) readline_omit__names: normally hitting <tab> after a '.' in a name
3613 # will complete all attributes of an object, including all the special methods
3623 # will complete all attributes of an object, including all the special methods
3614 # whose names start with single or double underscores (like __getitem__ or
3624 # whose names start with single or double underscores (like __getitem__ or
3615 # __class__).
3625 # __class__).
3616
3626
3617 # This variable allows you to control this completion behavior:
3627 # This variable allows you to control this completion behavior:
3618
3628
3619 # readline_omit__names 1 -> completion will omit showing any names starting
3629 # readline_omit__names 1 -> completion will omit showing any names starting
3620 # with two __, but it will still show names starting with one _.
3630 # with two __, but it will still show names starting with one _.
3621
3631
3622 # readline_omit__names 2 -> completion will omit all names beginning with one
3632 # readline_omit__names 2 -> completion will omit all names beginning with one
3623 # _ (which obviously means filtering out the double __ ones).
3633 # _ (which obviously means filtering out the double __ ones).
3624
3634
3625 # Even when this option is set, you can still see those names by explicitly
3635 # Even when this option is set, you can still see those names by explicitly
3626 # typing a _ after the period and hitting <tab>: 'name._<tab>' will always
3636 # typing a _ after the period and hitting <tab>: 'name._<tab>' will always
3627 # complete attribute names starting with '_'.
3637 # complete attribute names starting with '_'.
3628
3638
3629 # This option is off by default so that new users see all attributes of any
3639 # This option is off by default so that new users see all attributes of any
3630 # objects they are dealing with.
3640 # objects they are dealing with.
3631
3641
3632 readline_omit__names 0
3642 readline_omit__names 0
3633
3643
3634 #---------------------------------------------------------------------------
3644 #---------------------------------------------------------------------------
3635 # Section: modules to be loaded with 'import ...'
3645 # Section: modules to be loaded with 'import ...'
3636
3646
3637 # List, separated by spaces, the names of the modules you want to import
3647 # List, separated by spaces, the names of the modules you want to import
3638
3648
3639 # Example:
3649 # Example:
3640 # import_mod sys os
3650 # import_mod sys os
3641 # will produce internally the statements
3651 # will produce internally the statements
3642 # import sys
3652 # import sys
3643 # import os
3653 # import os
3644
3654
3645 # Each import is executed in its own try/except block, so if one module
3655 # Each import is executed in its own try/except block, so if one module
3646 # fails to load the others will still be ok.
3656 # fails to load the others will still be ok.
3647
3657
3648 import_mod
3658 import_mod
3649
3659
3650 #---------------------------------------------------------------------------
3660 #---------------------------------------------------------------------------
3651 # Section: modules to import some functions from: 'from ... import ...'
3661 # Section: modules to import some functions from: 'from ... import ...'
3652
3662
3653 # List, one per line, the modules for which you want only to import some
3663 # List, one per line, the modules for which you want only to import some
3654 # functions. Give the module name first and then the name of functions to be
3664 # functions. Give the module name first and then the name of functions to be
3655 # imported from that module.
3665 # imported from that module.
3656
3666
3657 # Example:
3667 # Example:
3658
3668
3659 # import_some IPython.genutils timing timings
3669 # import_some IPython.genutils timing timings
3660 # will produce internally the statement
3670 # will produce internally the statement
3661 # from IPython.genutils import timing, timings
3671 # from IPython.genutils import timing, timings
3662
3672
3663 # timing() and timings() are two IPython utilities for timing the execution of
3673 # timing() and timings() are two IPython utilities for timing the execution of
3664 # your own functions, which you may find useful. Just commment out the above
3674 # your own functions, which you may find useful. Just commment out the above
3665 # line if you want to test them.
3675 # line if you want to test them.
3666
3676
3667 # If you have more than one modules_some line, each gets its own try/except
3677 # If you have more than one modules_some line, each gets its own try/except
3668 # block (like modules, see above).
3678 # block (like modules, see above).
3669
3679
3670 import_some
3680 import_some
3671
3681
3672 #---------------------------------------------------------------------------
3682 #---------------------------------------------------------------------------
3673 # Section: modules to import all from : 'from ... import *'
3683 # Section: modules to import all from : 'from ... import *'
3674
3684
3675 # List (same syntax as import_mod above) those modules for which you want to
3685 # List (same syntax as import_mod above) those modules for which you want to
3676 # import all functions. Remember, this is a potentially dangerous thing to do,
3686 # import all functions. Remember, this is a potentially dangerous thing to do,
3677 # since it is very easy to overwrite names of things you need. Use with
3687 # since it is very easy to overwrite names of things you need. Use with
3678 # caution.
3688 # caution.
3679
3689
3680 # Example:
3690 # Example:
3681 # import_all sys os
3691 # import_all sys os
3682 # will produce internally the statements
3692 # will produce internally the statements
3683 # from sys import *
3693 # from sys import *
3684 # from os import *
3694 # from os import *
3685
3695
3686 # As before, each will be called in a separate try/except block.
3696 # As before, each will be called in a separate try/except block.
3687
3697
3688 import_all
3698 import_all
3689
3699
3690 #---------------------------------------------------------------------------
3700 #---------------------------------------------------------------------------
3691 # Section: Python code to execute.
3701 # Section: Python code to execute.
3692
3702
3693 # Put here code to be explicitly executed (keep it simple!)
3703 # Put here code to be explicitly executed (keep it simple!)
3694 # Put one line of python code per line. All whitespace is removed (this is a
3704 # Put one line of python code per line. All whitespace is removed (this is a
3695 # feature, not a bug), so don't get fancy building loops here.
3705 # feature, not a bug), so don't get fancy building loops here.
3696 # This is just for quick convenient creation of things you want available.
3706 # This is just for quick convenient creation of things you want available.
3697
3707
3698 # Example:
3708 # Example:
3699 # execute x = 1
3709 # execute x = 1
3700 # execute print 'hello world'; y = z = 'a'
3710 # execute print 'hello world'; y = z = 'a'
3701 # will produce internally
3711 # will produce internally
3702 # x = 1
3712 # x = 1
3703 # print 'hello world'; y = z = 'a'
3713 # print 'hello world'; y = z = 'a'
3704 # and each *line* (not each statement, we don't do python syntax parsing) is
3714 # and each *line* (not each statement, we don't do python syntax parsing) is
3705 # executed in its own try/except block.
3715 # executed in its own try/except block.
3706
3716
3707 execute
3717 execute
3708
3718
3709 # Note for the adventurous: you can use this to define your own names for the
3719 # Note for the adventurous: you can use this to define your own names for the
3710 # magic functions, by playing some namespace tricks:
3720 # magic functions, by playing some namespace tricks:
3711
3721
3712 # execute __IPYTHON__.magic_pf = __IPYTHON__.magic_profile
3722 # execute __IPYTHON__.magic_pf = __IPYTHON__.magic_profile
3713
3723
3714 # defines %pf as a new name for %profile.
3724 # defines %pf as a new name for %profile.
3715
3725
3716 #---------------------------------------------------------------------------
3726 #---------------------------------------------------------------------------
3717 # Section: Pyhton files to load and execute.
3727 # Section: Pyhton files to load and execute.
3718
3728
3719 # Put here the full names of files you want executed with execfile(file). If
3729 # Put here the full names of files you want executed with execfile(file). If
3720 # you want complicated initialization, just write whatever you want in a
3730 # you want complicated initialization, just write whatever you want in a
3721 # regular python file and load it from here.
3731 # regular python file and load it from here.
3722
3732
3723 # Filenames defined here (which *must* include the extension) are searched for
3733 # Filenames defined here (which *must* include the extension) are searched for
3724 # through all of sys.path. Since IPython adds your .ipython directory to
3734 # through all of sys.path. Since IPython adds your .ipython directory to
3725 # sys.path, they can also be placed in your .ipython dir and will be
3735 # sys.path, they can also be placed in your .ipython dir and will be
3726 # found. Otherwise (if you want to execute things not in .ipyton nor in
3736 # found. Otherwise (if you want to execute things not in .ipyton nor in
3727 # sys.path) give a full path (you can use ~, it gets expanded)
3737 # sys.path) give a full path (you can use ~, it gets expanded)
3728
3738
3729 # Example:
3739 # Example:
3730 # execfile file1.py ~/file2.py
3740 # execfile file1.py ~/file2.py
3731 # will generate
3741 # will generate
3732 # execfile('file1.py')
3742 # execfile('file1.py')
3733 # execfile('_path_to_your_home/file2.py')
3743 # execfile('_path_to_your_home/file2.py')
3734
3744
3735 # As before, each file gets its own try/except block.
3745 # As before, each file gets its own try/except block.
3736
3746
3737 execfile
3747 execfile
3738
3748
3739 # If you are feeling adventurous, you can even add functionality to IPython
3749 # If you are feeling adventurous, you can even add functionality to IPython
3740 # through here. IPython works through a global variable called __ip which
3750 # through here. IPython works through a global variable called __ip which
3741 # exists at the time when these files are read. If you know what you are doing
3751 # exists at the time when these files are read. If you know what you are doing
3742 # (read the source) you can add functions to __ip in files loaded here.
3752 # (read the source) you can add functions to __ip in files loaded here.
3743
3753
3744 # The file example-magic.py contains a simple but correct example. Try it:
3754 # The file example-magic.py contains a simple but correct example. Try it:
3745
3755
3746 # execfile example-magic.py
3756 # execfile example-magic.py
3747
3757
3748 # Look at the examples in IPython/iplib.py for more details on how these magic
3758 # Look at the examples in IPython/iplib.py for more details on how these magic
3749 # functions need to process their arguments.
3759 # functions need to process their arguments.
3750
3760
3751 #---------------------------------------------------------------------------
3761 #---------------------------------------------------------------------------
3752 # Section: aliases for system shell commands
3762 # Section: aliases for system shell commands
3753
3763
3754 # Here you can define your own names for system commands. The syntax is
3764 # Here you can define your own names for system commands. The syntax is
3755 # similar to that of the builtin %alias function:
3765 # similar to that of the builtin %alias function:
3756
3766
3757 # alias alias_name command_string
3767 # alias alias_name command_string
3758
3768
3759 # The resulting aliases are auto-generated magic functions (hence usable as
3769 # The resulting aliases are auto-generated magic functions (hence usable as
3760 # %alias_name)
3770 # %alias_name)
3761
3771
3762 # For example:
3772 # For example:
3763
3773
3764 # alias myls ls -la
3774 # alias myls ls -la
3765
3775
3766 # will define 'myls' as an alias for executing the system command 'ls -la'.
3776 # will define 'myls' as an alias for executing the system command 'ls -la'.
3767 # This allows you to customize IPython's environment to have the same aliases
3777 # This allows you to customize IPython's environment to have the same aliases
3768 # you are accustomed to from your own shell.
3778 # you are accustomed to from your own shell.
3769
3779
3770 # You can also define aliases with parameters using %s specifiers (one per
3780 # You can also define aliases with parameters using %s specifiers (one per
3771 # parameter):
3781 # parameter):
3772
3782
3773 # alias parts echo first %s second %s
3783 # alias parts echo first %s second %s
3774
3784
3775 # will give you in IPython:
3785 # will give you in IPython:
3776 # >>> %parts A B
3786 # >>> %parts A B
3777 # first A second B
3787 # first A second B
3778
3788
3779 # Use one 'alias' statement per alias you wish to define.
3789 # Use one 'alias' statement per alias you wish to define.
3780
3790
3781 # alias
3791 # alias
3782
3792
3783 #************************* end of file <ipythonrc> ************************
3793 #************************* end of file <ipythonrc> ************************
3784
3794
3785
3795
3786
3796
3787 Fine-tuning your prompt
3797 Fine-tuning your prompt
3788 -----------------------
3798 -----------------------
3789
3799
3790 IPython's prompts can be customized using a syntax similar to that of
3800 IPython's prompts can be customized using a syntax similar to that of
3791 the bash shell. Many of bash's escapes are supported, as well as a few
3801 the bash shell. Many of bash's escapes are supported, as well as a few
3792 additional ones. We list them below:
3802 additional ones. We list them below:
3793
3803
3794 *\#*
3804 *\#*
3795 the prompt/history count number. This escape is automatically
3805 the prompt/history count number. This escape is automatically
3796 wrapped in the coloring codes for the currently active color scheme.
3806 wrapped in the coloring codes for the currently active color scheme.
3797 *\N*
3807 *\N*
3798 the 'naked' prompt/history count number: this is just the number
3808 the 'naked' prompt/history count number: this is just the number
3799 itself, without any coloring applied to it. This lets you produce
3809 itself, without any coloring applied to it. This lets you produce
3800 numbered prompts with your own colors.
3810 numbered prompts with your own colors.
3801 *\D*
3811 *\D*
3802 the prompt/history count, with the actual digits replaced by dots.
3812 the prompt/history count, with the actual digits replaced by dots.
3803 Used mainly in continuation prompts (prompt_in2)
3813 Used mainly in continuation prompts (prompt_in2)
3804 *\w*
3814 *\w*
3805 the current working directory
3815 the current working directory
3806 *\W*
3816 *\W*
3807 the basename of current working directory
3817 the basename of current working directory
3808 *\Xn*
3818 *\Xn*
3809 where $n=0\ldots5.$ The current working directory, with $HOME
3819 where $n=0\ldots5.$ The current working directory, with $HOME
3810 replaced by ~, and filtered out to contain only $n$ path elements
3820 replaced by ~, and filtered out to contain only $n$ path elements
3811 *\Yn*
3821 *\Yn*
3812 Similar to \Xn, but with the $n+1$ element included if it is ~ (this
3822 Similar to \Xn, but with the $n+1$ element included if it is ~ (this
3813 is similar to the behavior of the %cn escapes in tcsh)
3823 is similar to the behavior of the %cn escapes in tcsh)
3814 *\u*
3824 *\u*
3815 the username of the current user
3825 the username of the current user
3816 *\$*
3826 *\$*
3817 if the effective UID is 0, a #, otherwise a $
3827 if the effective UID is 0, a #, otherwise a $
3818 *\h*
3828 *\h*
3819 the hostname up to the first '.'
3829 the hostname up to the first '.'
3820 *\H*
3830 *\H*
3821 the hostname
3831 the hostname
3822 *\n*
3832 *\n*
3823 a newline
3833 a newline
3824 *\r*
3834 *\r*
3825 a carriage return
3835 a carriage return
3826 *\v*
3836 *\v*
3827 IPython version string
3837 IPython version string
3828
3838
3829 In addition to these, ANSI color escapes can be insterted into the
3839 In addition to these, ANSI color escapes can be insterted into the
3830 prompts, as \C_ColorName. The list of valid color names is: Black, Blue,
3840 prompts, as \C_ColorName. The list of valid color names is: Black, Blue,
3831 Brown, Cyan, DarkGray, Green, LightBlue, LightCyan, LightGray,
3841 Brown, Cyan, DarkGray, Green, LightBlue, LightCyan, LightGray,
3832 LightGreen, LightPurple, LightRed, NoColor, Normal, Purple, Red, White,
3842 LightGreen, LightPurple, LightRed, NoColor, Normal, Purple, Red, White,
3833 Yellow.
3843 Yellow.
3834
3844
3835 Finally, IPython supports the evaluation of arbitrary expressions in
3845 Finally, IPython supports the evaluation of arbitrary expressions in
3836 your prompt string. The prompt strings are evaluated through the syntax
3846 your prompt string. The prompt strings are evaluated through the syntax
3837 of PEP 215, but basically you can use $x.y to expand the value of x.y,
3847 of PEP 215, but basically you can use $x.y to expand the value of x.y,
3838 and for more complicated expressions you can use braces: ${foo()+x} will
3848 and for more complicated expressions you can use braces: ${foo()+x} will
3839 call function foo and add to it the value of x, before putting the
3849 call function foo and add to it the value of x, before putting the
3840 result into your prompt. For example, using
3850 result into your prompt. For example, using
3841 prompt_in1 '${commands.getoutput("uptime")}\nIn [\#]: '
3851 prompt_in1 '${commands.getoutput("uptime")}\nIn [\#]: '
3842 will print the result of the uptime command on each prompt (assuming the
3852 will print the result of the uptime command on each prompt (assuming the
3843 commands module has been imported in your ipythonrc file).
3853 commands module has been imported in your ipythonrc file).
3844
3854
3845
3855
3846 Prompt examples
3856 Prompt examples
3847
3857
3848 The following options in an ipythonrc file will give you IPython's
3858 The following options in an ipythonrc file will give you IPython's
3849 default prompts::
3859 default prompts::
3850
3860
3851 prompt_in1 'In [\#]:'
3861 prompt_in1 'In [\#]:'
3852 prompt_in2 ' .\D.:'
3862 prompt_in2 ' .\D.:'
3853 prompt_out 'Out[\#]:'
3863 prompt_out 'Out[\#]:'
3854
3864
3855 which look like this::
3865 which look like this::
3856
3866
3857 In [1]: 1+2
3867 In [1]: 1+2
3858 Out[1]: 3
3868 Out[1]: 3
3859
3869
3860 In [2]: for i in (1,2,3):
3870 In [2]: for i in (1,2,3):
3861 ...: print i,
3871 ...: print i,
3862 ...:
3872 ...:
3863 1 2 3
3873 1 2 3
3864
3874
3865 These will give you a very colorful prompt with path information::
3875 These will give you a very colorful prompt with path information::
3866
3876
3867 #prompt_in1 '\C_Red\u\C_Blue[\C_Cyan\Y1\C_Blue]\C_LightGreen\#>'
3877 #prompt_in1 '\C_Red\u\C_Blue[\C_Cyan\Y1\C_Blue]\C_LightGreen\#>'
3868 prompt_in2 ' ..\D>'
3878 prompt_in2 ' ..\D>'
3869 prompt_out '<\#>'
3879 prompt_out '<\#>'
3870
3880
3871 which look like this::
3881 which look like this::
3872
3882
3873 fperez[~/ipython]1> 1+2
3883 fperez[~/ipython]1> 1+2
3874 <1> 3
3884 <1> 3
3875 fperez[~/ipython]2> for i in (1,2,3):
3885 fperez[~/ipython]2> for i in (1,2,3):
3876 ...> print i,
3886 ...> print i,
3877 ...>
3887 ...>
3878 1 2 3
3888 1 2 3
3879
3889
3880
3890
3881
3891
3882 IPython profiles
3892 IPython profiles
3883 ----------------
3893 ----------------
3884
3894
3885 As we already mentioned, IPython supports the -profile command-line
3895 As we already mentioned, IPython supports the -profile command-line
3886 option (see sec. 5.2 <node5.html#sec:cmd-line-opts>). A profile is
3896 option (see sec. 5.2 <node5.html#sec:cmd-line-opts>). A profile is
3887 nothing more than a particular configuration file like your basic
3897 nothing more than a particular configuration file like your basic
3888 ipythonrc one, but with particular customizations for a specific
3898 ipythonrc one, but with particular customizations for a specific
3889 purpose. When you start IPython with 'ipython -profile <name>', it
3899 purpose. When you start IPython with 'ipython -profile <name>', it
3890 assumes that in your IPYTHONDIR there is a file called ipythonrc-<name>,
3900 assumes that in your IPYTHONDIR there is a file called ipythonrc-<name>,
3891 and loads it instead of the normal ipythonrc.
3901 and loads it instead of the normal ipythonrc.
3892
3902
3893 This system allows you to maintain multiple configurations which load
3903 This system allows you to maintain multiple configurations which load
3894 modules, set options, define functions, etc. suitable for different
3904 modules, set options, define functions, etc. suitable for different
3895 tasks and activate them in a very simple manner. In order to avoid
3905 tasks and activate them in a very simple manner. In order to avoid
3896 having to repeat all of your basic options (common things that don't
3906 having to repeat all of your basic options (common things that don't
3897 change such as your color preferences, for example), any profile can
3907 change such as your color preferences, for example), any profile can
3898 include another configuration file. The most common way to use profiles
3908 include another configuration file. The most common way to use profiles
3899 is then to have each one include your basic ipythonrc file as a starting
3909 is then to have each one include your basic ipythonrc file as a starting
3900 point, and then add further customizations.
3910 point, and then add further customizations.
3901
3911
3902 In sections 11 <node11.html#sec:syntax-extensions> and 16
3912 In sections 11 <node11.html#sec:syntax-extensions> and 16
3903 <node16.html#sec:Gnuplot> we discuss some particular profiles which come
3913 <node16.html#sec:Gnuplot> we discuss some particular profiles which come
3904 as part of the standard IPython distribution. You may also look in your
3914 as part of the standard IPython distribution. You may also look in your
3905 IPYTHONDIR directory, any file whose name begins with ipythonrc- is a
3915 IPYTHONDIR directory, any file whose name begins with ipythonrc- is a
3906 profile. You can use those as examples for further customizations to
3916 profile. You can use those as examples for further customizations to
3907 suit your own needs.
3917 suit your own needs.
3908
3918
3909 IPython as your default Python environment
3919 IPython as your default Python environment
3910 ==========================================
3920 ==========================================
3911
3921
3912 Python honors the environment variable PYTHONSTARTUP and will execute at
3922 Python honors the environment variable PYTHONSTARTUP and will execute at
3913 startup the file referenced by this variable. If you put at the end of
3923 startup the file referenced by this variable. If you put at the end of
3914 this file the following two lines of code::
3924 this file the following two lines of code::
3915
3925
3916 import IPython
3926 import IPython
3917 IPython.Shell.IPShell().mainloop(sys_exit=1)
3927 IPython.Shell.IPShell().mainloop(sys_exit=1)
3918
3928
3919 then IPython will be your working environment anytime you start Python.
3929 then IPython will be your working environment anytime you start Python.
3920 The sys_exit=1 is needed to have IPython issue a call to sys.exit() when
3930 The sys_exit=1 is needed to have IPython issue a call to sys.exit() when
3921 it finishes, otherwise you'll be back at the normal Python '>>>'
3931 it finishes, otherwise you'll be back at the normal Python '>>>'
3922 prompt^4 <footnode.html#foot2368>.
3932 prompt^4 <footnode.html#foot2368>.
3923
3933
3924 This is probably useful to developers who manage multiple Python
3934 This is probably useful to developers who manage multiple Python
3925 versions and don't want to have correspondingly multiple IPython
3935 versions and don't want to have correspondingly multiple IPython
3926 versions. Note that in this mode, there is no way to pass IPython any
3936 versions. Note that in this mode, there is no way to pass IPython any
3927 command-line options, as those are trapped first by Python itself.
3937 command-line options, as those are trapped first by Python itself.
3928
3938
3929 Embedding IPython
3939 Embedding IPython
3930 =================
3940 =================
3931
3941
3932 It is possible to start an IPython instance inside your own Python
3942 It is possible to start an IPython instance inside your own Python
3933 programs. This allows you to evaluate dynamically the state of your
3943 programs. This allows you to evaluate dynamically the state of your
3934 code, operate with your variables, analyze them, etc. Note however that
3944 code, operate with your variables, analyze them, etc. Note however that
3935 any changes you make to values while in the shell do not propagate back
3945 any changes you make to values while in the shell do not propagate back
3936 to the running code, so it is safe to modify your values because you
3946 to the running code, so it is safe to modify your values because you
3937 won't break your code in bizarre ways by doing so.
3947 won't break your code in bizarre ways by doing so.
3938
3948
3939 This feature allows you to easily have a fully functional python
3949 This feature allows you to easily have a fully functional python
3940 environment for doing object introspection anywhere in your code with a
3950 environment for doing object introspection anywhere in your code with a
3941 simple function call. In some cases a simple print statement is enough,
3951 simple function call. In some cases a simple print statement is enough,
3942 but if you need to do more detailed analysis of a code fragment this
3952 but if you need to do more detailed analysis of a code fragment this
3943 feature can be very valuable.
3953 feature can be very valuable.
3944
3954
3945 It can also be useful in scientific computing situations where it is
3955 It can also be useful in scientific computing situations where it is
3946 common to need to do some automatic, computationally intensive part and
3956 common to need to do some automatic, computationally intensive part and
3947 then stop to look at data, plots, etc^5 <footnode.html#foot3206>.
3957 then stop to look at data, plots, etc^5 <footnode.html#foot3206>.
3948 Opening an IPython instance will give you full access to your data and
3958 Opening an IPython instance will give you full access to your data and
3949 functions, and you can resume program execution once you are done with
3959 functions, and you can resume program execution once you are done with
3950 the interactive part (perhaps to stop again later, as many times as
3960 the interactive part (perhaps to stop again later, as many times as
3951 needed).
3961 needed).
3952
3962
3953 The following code snippet is the bare minimum you need to include in
3963 The following code snippet is the bare minimum you need to include in
3954 your Python programs for this to work (detailed examples follow later)::
3964 your Python programs for this to work (detailed examples follow later)::
3955
3965
3956 from IPython.Shell import IPShellEmbed
3966 from IPython.Shell import IPShellEmbed
3957
3967
3958 ipshell = IPShellEmbed()
3968 ipshell = IPShellEmbed()
3959
3969
3960 ipshell() # this call anywhere in your program will start IPython
3970 ipshell() # this call anywhere in your program will start IPython
3961
3971
3962 You can run embedded instances even in code which is itself being run at
3972 You can run embedded instances even in code which is itself being run at
3963 the IPython interactive prompt with '%run <filename>'. Since it's easy
3973 the IPython interactive prompt with '%run <filename>'. Since it's easy
3964 to get lost as to where you are (in your top-level IPython or in your
3974 to get lost as to where you are (in your top-level IPython or in your
3965 embedded one), it's a good idea in such cases to set the in/out prompts
3975 embedded one), it's a good idea in such cases to set the in/out prompts
3966 to something different for the embedded instances. The code examples
3976 to something different for the embedded instances. The code examples
3967 below illustrate this.
3977 below illustrate this.
3968
3978
3969 You can also have multiple IPython instances in your program and open
3979 You can also have multiple IPython instances in your program and open
3970 them separately, for example with different options for data
3980 them separately, for example with different options for data
3971 presentation. If you close and open the same instance multiple times,
3981 presentation. If you close and open the same instance multiple times,
3972 its prompt counters simply continue from each execution to the next.
3982 its prompt counters simply continue from each execution to the next.
3973
3983
3974 Please look at the docstrings in the Shell.py module for more details on
3984 Please look at the docstrings in the Shell.py module for more details on
3975 the use of this system.
3985 the use of this system.
3976
3986
3977 The following sample file illustrating how to use the embedding
3987 The following sample file illustrating how to use the embedding
3978 functionality is provided in the examples directory as example-embed.py.
3988 functionality is provided in the examples directory as example-embed.py.
3979 It should be fairly self-explanatory::
3989 It should be fairly self-explanatory::
3980
3990
3981
3991
3982 #!/usr/bin/env python
3992 #!/usr/bin/env python
3983
3993
3984 """An example of how to embed an IPython shell into a running program.
3994 """An example of how to embed an IPython shell into a running program.
3985
3995
3986 Please see the documentation in the IPython.Shell module for more details.
3996 Please see the documentation in the IPython.Shell module for more details.
3987
3997
3988 The accompanying file example-embed-short.py has quick code fragments for
3998 The accompanying file example-embed-short.py has quick code fragments for
3989 embedding which you can cut and paste in your code once you understand how
3999 embedding which you can cut and paste in your code once you understand how
3990 things work.
4000 things work.
3991
4001
3992 The code in this file is deliberately extra-verbose, meant for learning."""
4002 The code in this file is deliberately extra-verbose, meant for learning."""
3993
4003
3994 # The basics to get you going:
4004 # The basics to get you going:
3995
4005
3996 # IPython sets the __IPYTHON__ variable so you can know if you have nested
4006 # IPython sets the __IPYTHON__ variable so you can know if you have nested
3997 # copies running.
4007 # copies running.
3998
4008
3999 # Try running this code both at the command line and from inside IPython (with
4009 # Try running this code both at the command line and from inside IPython (with
4000 # %run example-embed.py)
4010 # %run example-embed.py)
4001 try:
4011 try:
4002 __IPYTHON__
4012 __IPYTHON__
4003 except NameError:
4013 except NameError:
4004 nested = 0
4014 nested = 0
4005 args = ['']
4015 args = ['']
4006 else:
4016 else:
4007 print "Running nested copies of IPython."
4017 print "Running nested copies of IPython."
4008 print "The prompts for the nested copy have been modified"
4018 print "The prompts for the nested copy have been modified"
4009 nested = 1
4019 nested = 1
4010 # what the embedded instance will see as sys.argv:
4020 # what the embedded instance will see as sys.argv:
4011 args = ['-pi1','In <\\#>: ','-pi2',' .\\D.: ',
4021 args = ['-pi1','In <\\#>: ','-pi2',' .\\D.: ',
4012 '-po','Out<\\#>: ','-nosep']
4022 '-po','Out<\\#>: ','-nosep']
4013
4023
4014 # First import the embeddable shell class
4024 # First import the embeddable shell class
4015 from IPython.Shell import IPShellEmbed
4025 from IPython.Shell import IPShellEmbed
4016
4026
4017 # Now create an instance of the embeddable shell. The first argument is a
4027 # Now create an instance of the embeddable shell. The first argument is a
4018 # string with options exactly as you would type them if you were starting
4028 # string with options exactly as you would type them if you were starting
4019 # IPython at the system command line. Any parameters you want to define for
4029 # IPython at the system command line. Any parameters you want to define for
4020 # configuration can thus be specified here.
4030 # configuration can thus be specified here.
4021 ipshell = IPShellEmbed(args,
4031 ipshell = IPShellEmbed(args,
4022 banner = 'Dropping into IPython',
4032 banner = 'Dropping into IPython',
4023 exit_msg = 'Leaving Interpreter, back to program.')
4033 exit_msg = 'Leaving Interpreter, back to program.')
4024
4034
4025 # Make a second instance, you can have as many as you want.
4035 # Make a second instance, you can have as many as you want.
4026 if nested:
4036 if nested:
4027 args[1] = 'In2<\\#>'
4037 args[1] = 'In2<\\#>'
4028 else:
4038 else:
4029 args = ['-pi1','In2<\\#>: ','-pi2',' .\\D.: ',
4039 args = ['-pi1','In2<\\#>: ','-pi2',' .\\D.: ',
4030 '-po','Out<\\#>: ','-nosep']
4040 '-po','Out<\\#>: ','-nosep']
4031 ipshell2 = IPShellEmbed(args,banner = 'Second IPython instance.')
4041 ipshell2 = IPShellEmbed(args,banner = 'Second IPython instance.')
4032
4042
4033 print '\nHello. This is printed from the main controller program.\n'
4043 print '\nHello. This is printed from the main controller program.\n'
4034
4044
4035 # You can then call ipshell() anywhere you need it (with an optional
4045 # You can then call ipshell() anywhere you need it (with an optional
4036 # message):
4046 # message):
4037 ipshell('***Called from top level. '
4047 ipshell('***Called from top level. '
4038 'Hit Ctrl-D to exit interpreter and continue program.\n'
4048 'Hit Ctrl-D to exit interpreter and continue program.\n'
4039 'Note that if you use %kill_embedded, you can fully deactivate\n'
4049 'Note that if you use %kill_embedded, you can fully deactivate\n'
4040 'This embedded instance so it will never turn on again')
4050 'This embedded instance so it will never turn on again')
4041
4051
4042 print '\nBack in caller program, moving along...\n'
4052 print '\nBack in caller program, moving along...\n'
4043
4053
4044 #---------------------------------------------------------------------------
4054 #---------------------------------------------------------------------------
4045 # More details:
4055 # More details:
4046
4056
4047 # IPShellEmbed instances don't print the standard system banner and
4057 # IPShellEmbed instances don't print the standard system banner and
4048 # messages. The IPython banner (which actually may contain initialization
4058 # messages. The IPython banner (which actually may contain initialization
4049 # messages) is available as <instance>.IP.BANNER in case you want it.
4059 # messages) is available as <instance>.IP.BANNER in case you want it.
4050
4060
4051 # IPShellEmbed instances print the following information everytime they
4061 # IPShellEmbed instances print the following information everytime they
4052 # start:
4062 # start:
4053
4063
4054 # - A global startup banner.
4064 # - A global startup banner.
4055
4065
4056 # - A call-specific header string, which you can use to indicate where in the
4066 # - A call-specific header string, which you can use to indicate where in the
4057 # execution flow the shell is starting.
4067 # execution flow the shell is starting.
4058
4068
4059 # They also print an exit message every time they exit.
4069 # They also print an exit message every time they exit.
4060
4070
4061 # Both the startup banner and the exit message default to None, and can be set
4071 # Both the startup banner and the exit message default to None, and can be set
4062 # either at the instance constructor or at any other time with the
4072 # either at the instance constructor or at any other time with the
4063 # set_banner() and set_exit_msg() methods.
4073 # set_banner() and set_exit_msg() methods.
4064
4074
4065 # The shell instance can be also put in 'dummy' mode globally or on a per-call
4075 # The shell instance can be also put in 'dummy' mode globally or on a per-call
4066 # basis. This gives you fine control for debugging without having to change
4076 # basis. This gives you fine control for debugging without having to change
4067 # code all over the place.
4077 # code all over the place.
4068
4078
4069 # The code below illustrates all this.
4079 # The code below illustrates all this.
4070
4080
4071
4081
4072 # This is how the global banner and exit_msg can be reset at any point
4082 # This is how the global banner and exit_msg can be reset at any point
4073 ipshell.set_banner('Entering interpreter - New Banner')
4083 ipshell.set_banner('Entering interpreter - New Banner')
4074 ipshell.set_exit_msg('Leaving interpreter - New exit_msg')
4084 ipshell.set_exit_msg('Leaving interpreter - New exit_msg')
4075
4085
4076 def foo(m):
4086 def foo(m):
4077 s = 'spam'
4087 s = 'spam'
4078 ipshell('***In foo(). Try @whos, or print s or m:')
4088 ipshell('***In foo(). Try @whos, or print s or m:')
4079 print 'foo says m = ',m
4089 print 'foo says m = ',m
4080
4090
4081 def bar(n):
4091 def bar(n):
4082 s = 'eggs'
4092 s = 'eggs'
4083 ipshell('***In bar(). Try @whos, or print s or n:')
4093 ipshell('***In bar(). Try @whos, or print s or n:')
4084 print 'bar says n = ',n
4094 print 'bar says n = ',n
4085
4095
4086 # Some calls to the above functions which will trigger IPython:
4096 # Some calls to the above functions which will trigger IPython:
4087 print 'Main program calling foo("eggs")\n'
4097 print 'Main program calling foo("eggs")\n'
4088 foo('eggs')
4098 foo('eggs')
4089
4099
4090 # The shell can be put in 'dummy' mode where calls to it silently return. This
4100 # The shell can be put in 'dummy' mode where calls to it silently return. This
4091 # allows you, for example, to globally turn off debugging for a program with a
4101 # allows you, for example, to globally turn off debugging for a program with a
4092 # single call.
4102 # single call.
4093 ipshell.set_dummy_mode(1)
4103 ipshell.set_dummy_mode(1)
4094 print '\nTrying to call IPython which is now "dummy":'
4104 print '\nTrying to call IPython which is now "dummy":'
4095 ipshell()
4105 ipshell()
4096 print 'Nothing happened...'
4106 print 'Nothing happened...'
4097 # The global 'dummy' mode can still be overridden for a single call
4107 # The global 'dummy' mode can still be overridden for a single call
4098 print '\nOverriding dummy mode manually:'
4108 print '\nOverriding dummy mode manually:'
4099 ipshell(dummy=0)
4109 ipshell(dummy=0)
4100
4110
4101 # Reactivate the IPython shell
4111 # Reactivate the IPython shell
4102 ipshell.set_dummy_mode(0)
4112 ipshell.set_dummy_mode(0)
4103
4113
4104 print 'You can even have multiple embedded instances:'
4114 print 'You can even have multiple embedded instances:'
4105 ipshell2()
4115 ipshell2()
4106
4116
4107 print '\nMain program calling bar("spam")\n'
4117 print '\nMain program calling bar("spam")\n'
4108 bar('spam')
4118 bar('spam')
4109
4119
4110 print 'Main program finished. Bye!'
4120 print 'Main program finished. Bye!'
4111
4121
4112 #********************** End of file <example-embed.py> ***********************
4122 #********************** End of file <example-embed.py> ***********************
4113
4123
4114 Once you understand how the system functions, you can use the following
4124 Once you understand how the system functions, you can use the following
4115 code fragments in your programs which are ready for cut and paste::
4125 code fragments in your programs which are ready for cut and paste::
4116
4126
4117
4127
4118 """Quick code snippets for embedding IPython into other programs.
4128 """Quick code snippets for embedding IPython into other programs.
4119
4129
4120 See example-embed.py for full details, this file has the bare minimum code for
4130 See example-embed.py for full details, this file has the bare minimum code for
4121 cut and paste use once you understand how to use the system."""
4131 cut and paste use once you understand how to use the system."""
4122
4132
4123 #---------------------------------------------------------------------------
4133 #---------------------------------------------------------------------------
4124 # This code loads IPython but modifies a few things if it detects it's running
4134 # This code loads IPython but modifies a few things if it detects it's running
4125 # embedded in another IPython session (helps avoid confusion)
4135 # embedded in another IPython session (helps avoid confusion)
4126
4136
4127 try:
4137 try:
4128 __IPYTHON__
4138 __IPYTHON__
4129 except NameError:
4139 except NameError:
4130 argv = ['']
4140 argv = ['']
4131 banner = exit_msg = ''
4141 banner = exit_msg = ''
4132 else:
4142 else:
4133 # Command-line options for IPython (a list like sys.argv)
4143 # Command-line options for IPython (a list like sys.argv)
4134 argv = ['-pi1','In <\\#>:','-pi2',' .\\D.:','-po','Out<\\#>:']
4144 argv = ['-pi1','In <\\#>:','-pi2',' .\\D.:','-po','Out<\\#>:']
4135 banner = '*** Nested interpreter ***'
4145 banner = '*** Nested interpreter ***'
4136 exit_msg = '*** Back in main IPython ***'
4146 exit_msg = '*** Back in main IPython ***'
4137
4147
4138 # First import the embeddable shell class
4148 # First import the embeddable shell class
4139 from IPython.Shell import IPShellEmbed
4149 from IPython.Shell import IPShellEmbed
4140 # Now create the IPython shell instance. Put ipshell() anywhere in your code
4150 # Now create the IPython shell instance. Put ipshell() anywhere in your code
4141 # where you want it to open.
4151 # where you want it to open.
4142 ipshell = IPShellEmbed(argv,banner=banner,exit_msg=exit_msg)
4152 ipshell = IPShellEmbed(argv,banner=banner,exit_msg=exit_msg)
4143
4153
4144 #---------------------------------------------------------------------------
4154 #---------------------------------------------------------------------------
4145 # This code will load an embeddable IPython shell always with no changes for
4155 # This code will load an embeddable IPython shell always with no changes for
4146 # nested embededings.
4156 # nested embededings.
4147
4157
4148 from IPython.Shell import IPShellEmbed
4158 from IPython.Shell import IPShellEmbed
4149 ipshell = IPShellEmbed()
4159 ipshell = IPShellEmbed()
4150 # Now ipshell() will open IPython anywhere in the code.
4160 # Now ipshell() will open IPython anywhere in the code.
4151
4161
4152 #---------------------------------------------------------------------------
4162 #---------------------------------------------------------------------------
4153 # This code loads an embeddable shell only if NOT running inside
4163 # This code loads an embeddable shell only if NOT running inside
4154 # IPython. Inside IPython, the embeddable shell variable ipshell is just a
4164 # IPython. Inside IPython, the embeddable shell variable ipshell is just a
4155 # dummy function.
4165 # dummy function.
4156
4166
4157 try:
4167 try:
4158 __IPYTHON__
4168 __IPYTHON__
4159 except NameError:
4169 except NameError:
4160 from IPython.Shell import IPShellEmbed
4170 from IPython.Shell import IPShellEmbed
4161 ipshell = IPShellEmbed()
4171 ipshell = IPShellEmbed()
4162 # Now ipshell() will open IPython anywhere in the code
4172 # Now ipshell() will open IPython anywhere in the code
4163 else:
4173 else:
4164 # Define a dummy ipshell() so the same code doesn't crash inside an
4174 # Define a dummy ipshell() so the same code doesn't crash inside an
4165 # interactive IPython
4175 # interactive IPython
4166 def ipshell(): pass
4176 def ipshell(): pass
4167
4177
4168 #******************* End of file <example-embed-short.py> ********************
4178 #******************* End of file <example-embed-short.py> ********************
4169
4179
4170 Using the Python debugger (pdb)
4180 Using the Python debugger (pdb)
4171 ===============================
4181 ===============================
4172
4182
4173
4174 Running entire programs via pdb
4183 Running entire programs via pdb
4175 -------------------------------
4184 -------------------------------
4176
4185
4177 pdb, the Python debugger, is a powerful interactive debugger which
4186 pdb, the Python debugger, is a powerful interactive debugger which
4178 allows you to step through code, set breakpoints, watch variables, etc.
4187 allows you to step through code, set breakpoints, watch variables, etc.
4179 IPython makes it very easy to start any script under the control of pdb,
4188 IPython makes it very easy to start any script under the control of pdb,
4180 regardless of whether you have wrapped it into a 'main()' function or
4189 regardless of whether you have wrapped it into a 'main()' function or
4181 not. For this, simply type '%run -d myscript' at an IPython prompt. See
4190 not. For this, simply type '%run -d myscript' at an IPython prompt. See
4182 the %run command's documentation (via '%run?' or in Sec. 6.2
4191 the %run command's documentation (via '%run?' or in Sec. 6.2
4183 <node6.html#sec:magic>) for more details, including how to control where
4192 <node6.html#sec:magic>) for more details, including how to control where
4184 pdb will stop execution first.
4193 pdb will stop execution first.
4185
4194
4186 For more information on the use of the pdb debugger, read the included
4195 For more information on the use of the pdb debugger, read the included
4187 pdb.doc file (part of the standard Python distribution). On a stock
4196 pdb.doc file (part of the standard Python distribution). On a stock
4188 Linux system it is located at /usr/lib/python2.3/pdb.doc, but the
4197 Linux system it is located at /usr/lib/python2.3/pdb.doc, but the
4189 easiest way to read it is by using the help() function of the pdb module
4198 easiest way to read it is by using the help() function of the pdb module
4190 as follows (in an IPython prompt):
4199 as follows (in an IPython prompt):
4191
4200
4192 In [1]: import pdb
4201 In [1]: import pdb
4193 In [2]: pdb.help()
4202 In [2]: pdb.help()
4194
4203
4195 This will load the pdb.doc document in a file viewer for you automatically.
4204 This will load the pdb.doc document in a file viewer for you automatically.
4196
4205
4197
4206
4198 Automatic invocation of pdb on exceptions
4207 Automatic invocation of pdb on exceptions
4199 -----------------------------------------
4208 -----------------------------------------
4200
4209
4201 IPython, if started with the -pdb option (or if the option is set in
4210 IPython, if started with the -pdb option (or if the option is set in
4202 your rc file) can call the Python pdb debugger every time your code
4211 your rc file) can call the Python pdb debugger every time your code
4203 triggers an uncaught exception^6 <footnode.html#foot2403>. This feature
4212 triggers an uncaught exception^6 <footnode.html#foot2403>. This feature
4204 can also be toggled at any time with the %pdb magic command. This can be
4213 can also be toggled at any time with the %pdb magic command. This can be
4205 extremely useful in order to find the origin of subtle bugs, because pdb
4214 extremely useful in order to find the origin of subtle bugs, because pdb
4206 opens up at the point in your code which triggered the exception, and
4215 opens up at the point in your code which triggered the exception, and
4207 while your program is at this point 'dead', all the data is still
4216 while your program is at this point 'dead', all the data is still
4208 available and you can walk up and down the stack frame and understand
4217 available and you can walk up and down the stack frame and understand
4209 the origin of the problem.
4218 the origin of the problem.
4210
4219
4211 Furthermore, you can use these debugging facilities both with the
4220 Furthermore, you can use these debugging facilities both with the
4212 embedded IPython mode and without IPython at all. For an embedded shell
4221 embedded IPython mode and without IPython at all. For an embedded shell
4213 (see sec. 9 <node9.html#sec:embed>), simply call the constructor with
4222 (see sec. 9 <node9.html#sec:embed>), simply call the constructor with
4214 '-pdb' in the argument string and automatically pdb will be called if an
4223 '-pdb' in the argument string and automatically pdb will be called if an
4215 uncaught exception is triggered by your code.
4224 uncaught exception is triggered by your code.
4216
4225
4217 For stand-alone use of the feature in your programs which do not use
4226 For stand-alone use of the feature in your programs which do not use
4218 IPython at all, put the following lines toward the top of your 'main'
4227 IPython at all, put the following lines toward the top of your 'main'
4219 routine:
4228 routine:
4220
4229
4221 import sys,IPython.ultraTB
4230 import sys,IPython.ultraTB
4222 sys.excepthook = IPython.ultraTB.FormattedTB(mode='Verbose',
4231 sys.excepthook = IPython.ultraTB.FormattedTB(mode='Verbose',
4223 color_scheme='Linux', call_pdb=1)
4232 color_scheme='Linux', call_pdb=1)
4224
4233
4225 The mode keyword can be either 'Verbose' or 'Plain', giving either very
4234 The mode keyword can be either 'Verbose' or 'Plain', giving either very
4226 detailed or normal tracebacks respectively. The color_scheme keyword can
4235 detailed or normal tracebacks respectively. The color_scheme keyword can
4227 be one of 'NoColor', 'Linux' (default) or 'LightBG'. These are the same
4236 be one of 'NoColor', 'Linux' (default) or 'LightBG'. These are the same
4228 options which can be set in IPython with -colors and -xmode.
4237 options which can be set in IPython with -colors and -xmode.
4229
4238
4230 This will give any of your programs detailed, colored tracebacks with
4239 This will give any of your programs detailed, colored tracebacks with
4231 automatic invocation of pdb.
4240 automatic invocation of pdb.
4232
4241
4233
4242
4234 Extensions for syntax processing
4243 Extensions for syntax processing
4235 ================================
4244 ================================
4236
4245
4237 This isn't for the faint of heart, because the potential for breaking
4246 This isn't for the faint of heart, because the potential for breaking
4238 things is quite high. But it can be a very powerful and useful feature.
4247 things is quite high. But it can be a very powerful and useful feature.
4239 In a nutshell, you can redefine the way IPython processes the user input
4248 In a nutshell, you can redefine the way IPython processes the user input
4240 line to accept new, special extensions to the syntax without needing to
4249 line to accept new, special extensions to the syntax without needing to
4241 change any of IPython's own code.
4250 change any of IPython's own code.
4242
4251
4243 In the IPython/Extensions directory you will find some examples
4252 In the IPython/Extensions directory you will find some examples
4244 supplied, which we will briefly describe now. These can be used 'as is'
4253 supplied, which we will briefly describe now. These can be used 'as is'
4245 (and both provide very useful functionality), or you can use them as a
4254 (and both provide very useful functionality), or you can use them as a
4246 starting point for writing your own extensions.
4255 starting point for writing your own extensions.
4247
4256
4248
4257
4249 Pasting of code starting with '»> ' or '... '
4258 Pasting of code starting with '»> ' or '... '
4250 ----------------------------------------------
4259 ----------------------------------------------
4251
4260
4252 In the python tutorial it is common to find code examples which have
4261 In the python tutorial it is common to find code examples which have
4253 been taken from real python sessions. The problem with those is that all
4262 been taken from real python sessions. The problem with those is that all
4254 the lines begin with either '>>> ' or '... ', which makes it impossible
4263 the lines begin with either '>>> ' or '... ', which makes it impossible
4255 to paste them all at once. One must instead do a line by line manual
4264 to paste them all at once. One must instead do a line by line manual
4256 copying, carefully removing the leading extraneous characters.
4265 copying, carefully removing the leading extraneous characters.
4257
4266
4258 This extension identifies those starting characters and removes them
4267 This extension identifies those starting characters and removes them
4259 from the input automatically, so that one can paste multi-line examples
4268 from the input automatically, so that one can paste multi-line examples
4260 directly into IPython, saving a lot of time. Please look at the file
4269 directly into IPython, saving a lot of time. Please look at the file
4261 InterpreterPasteInput.py in the IPython/Extensions directory for details
4270 InterpreterPasteInput.py in the IPython/Extensions directory for details
4262 on how this is done.
4271 on how this is done.
4263
4272
4264 IPython comes with a special profile enabling this feature, called
4273 IPython comes with a special profile enabling this feature, called
4265 tutorial. Simply start IPython via 'ipython -p tutorial' and the feature
4274 tutorial. Simply start IPython via 'ipython -p tutorial' and the feature
4266 will be available. In a normal IPython session you can activate the
4275 will be available. In a normal IPython session you can activate the
4267 feature by importing the corresponding module with:
4276 feature by importing the corresponding module with:
4268 In [1]: import IPython.Extensions.InterpreterPasteInput
4277 In [1]: import IPython.Extensions.InterpreterPasteInput
4269
4278
4270 The following is a 'screenshot' of how things work when this extension
4279 The following is a 'screenshot' of how things work when this extension
4271 is on, copying an example from the standard tutorial::
4280 is on, copying an example from the standard tutorial::
4272
4281
4273 IPython profile: tutorial
4282 IPython profile: tutorial
4274
4283
4275 *** Pasting of code with ">>>" or "..." has been enabled.
4284 *** Pasting of code with ">>>" or "..." has been enabled.
4276
4285
4277 In [1]: >>> def fib2(n): # return Fibonacci series up to n
4286 In [1]: >>> def fib2(n): # return Fibonacci series up to n
4278 ...: ... """Return a list containing the Fibonacci series up to
4287 ...: ... """Return a list containing the Fibonacci series up to
4279 n."""
4288 n."""
4280 ...: ... result = []
4289 ...: ... result = []
4281 ...: ... a, b = 0, 1
4290 ...: ... a, b = 0, 1
4282 ...: ... while b < n:
4291 ...: ... while b < n:
4283 ...: ... result.append(b) # see below
4292 ...: ... result.append(b) # see below
4284 ...: ... a, b = b, a+b
4293 ...: ... a, b = b, a+b
4285 ...: ... return result
4294 ...: ... return result
4286 ...:
4295 ...:
4287
4296
4288 In [2]: fib2(10)
4297 In [2]: fib2(10)
4289 Out[2]: [1, 1, 2, 3, 5, 8]
4298 Out[2]: [1, 1, 2, 3, 5, 8]
4290
4299
4291 Note that as currently written, this extension does not recognize
4300 Note that as currently written, this extension does not recognize
4292 IPython's prompts for pasting. Those are more complicated, since the
4301 IPython's prompts for pasting. Those are more complicated, since the
4293 user can change them very easily, they involve numbers and can vary in
4302 user can change them very easily, they involve numbers and can vary in
4294 length. One could however extract all the relevant information from the
4303 length. One could however extract all the relevant information from the
4295 IPython instance and build an appropriate regular expression. This is
4304 IPython instance and build an appropriate regular expression. This is
4296 left as an exercise for the reader.
4305 left as an exercise for the reader.
4297
4306
4298
4307
4299 Input of physical quantities with units
4308 Input of physical quantities with units
4300 ---------------------------------------
4309 ---------------------------------------
4301
4310
4302 The module PhysicalQInput allows a simplified form of input for physical
4311 The module PhysicalQInput allows a simplified form of input for physical
4303 quantities with units. This file is meant to be used in conjunction with
4312 quantities with units. This file is meant to be used in conjunction with
4304 the PhysicalQInteractive module (in the same directory) and
4313 the PhysicalQInteractive module (in the same directory) and
4305 Physics.PhysicalQuantities from Konrad Hinsen's ScientificPython
4314 Physics.PhysicalQuantities from Konrad Hinsen's ScientificPython
4306 (http://dirac.cnrs-orleans.fr/ScientificPython/).
4315 (http://dirac.cnrs-orleans.fr/ScientificPython/).
4307
4316
4308 The Physics.PhysicalQuantities module defines PhysicalQuantity objects,
4317 The Physics.PhysicalQuantities module defines PhysicalQuantity objects,
4309 but these must be declared as instances of a class. For example, to
4318 but these must be declared as instances of a class. For example, to
4310 define v as a velocity of 3 m/s, normally you would write::
4319 define v as a velocity of 3 m/s, normally you would write::
4311
4320
4312 In [1]: v = PhysicalQuantity(3,'m/s')
4321 In [1]: v = PhysicalQuantity(3,'m/s')
4313
4322
4314 Using the PhysicalQ_Input extension this can be input instead as:
4323 Using the PhysicalQ_Input extension this can be input instead as:
4315 In [1]: v = 3 m/s
4324 In [1]: v = 3 m/s
4316 which is much more convenient for interactive use (even though it is
4325 which is much more convenient for interactive use (even though it is
4317 blatantly invalid Python syntax).
4326 blatantly invalid Python syntax).
4318
4327
4319 The physics profile supplied with IPython (enabled via 'ipython -p
4328 The physics profile supplied with IPython (enabled via 'ipython -p
4320 physics') uses these extensions, which you can also activate with:
4329 physics') uses these extensions, which you can also activate with:
4321
4330
4322 from math import * # math MUST be imported BEFORE PhysicalQInteractive
4331 from math import * # math MUST be imported BEFORE PhysicalQInteractive
4323 from IPython.Extensions.PhysicalQInteractive import *
4332 from IPython.Extensions.PhysicalQInteractive import *
4324 import IPython.Extensions.PhysicalQInput
4333 import IPython.Extensions.PhysicalQInput
4325
4334
4326 IPython as a system shell
4327 =========================
4328
4335
4329 IPython ships with a special profile called pysh, which you can activate
4336 IPython as a system shell - the 'Sh' profile
4330 at the command line as 'ipython -p pysh'. This loads InterpreterExec,
4337 ============================================
4331 along with some additional facilities and a prompt customized for
4338
4332 filesystem navigation.
4339 The 'sh' profile optimizes IPython for system shell usage. Apart from
4340 certain job control functionality that is present in unix (ctrl+z does
4341 "suspend"), the sh profile should provide you with most of the
4342 functionality you use daily in system shell, and more. Invoke IPython
4343 in 'sh' profile by doing 'ipython -p sh', or (in win32) by launching
4344 the "pysh" shortcut in start menu.
4333
4345
4334 Note that this does not make IPython a full-fledged system shell. In
4346 If you want to use the features of sh profile as your defaults (which
4335 particular, it has no job control, so if you type Ctrl-Z (under Unix),
4347 might be a good idea if you use other profiles a lot of the time but
4336 you'll suspend pysh itself, not the process you just started.
4348 still want the convenience of sh profile), add "import ipy_profile_sh"
4349 to your ~/.ipython/ipy_user_conf.py.
4337
4350
4338 What the shell profile allows you to do is to use the convenient and
4351 The 'sh' profile is different from the default profile in that:
4339 powerful syntax of Python to do quick scripting at the command line.
4340 Below we describe some of its features.
4341
4352
4353 * Prompt shows the current directory
4354 * Spacing between prompts and input is more compact (no padding with
4355 empty lines). The startup banner is more compact as well.
4356 * System commands are directly available (in alias table) without
4357 requesting %rehashx - however, if you install new programs along
4358 your PATH, you might want to run %rehashx to update the persistent
4359 alias table
4360 * Macros are stored in raw format by default. That is, instead of
4361 '_ip.system("cat foo"), the macro will contain text 'cat foo')
4362 * Autocall is in full mode
4363 * Calling "up" does "cd .."
4364
4365 The 'sh' profile is different from the now-obsolete (and unavailable)
4366 'pysh' profile in that:
4367
4368 * '$$var = command' and '$var = command' syntax is not supported
4369 * anymore. Use 'var = !command' instead (incidentally, this is
4370 * available in all IPython profiles). Note that !!command *will*
4371 * work.
4342
4372
4343 Aliases
4373 Aliases
4344 -------
4374 -------
4345
4375
4346 All of your $PATH has been loaded as IPython aliases, so you should be
4376 All of your $PATH has been loaded as IPython aliases, so you should be
4347 able to type any normal system command and have it executed. See %alias?
4377 able to type any normal system command and have it executed. See
4348 and %unalias? for details on the alias facilities. See also %rehash? and
4378 %alias? and %unalias? for details on the alias facilities. See also
4349 %rehashx? for details on the mechanism used to load $PATH.
4379 %rehashx? for details on the mechanism used to load $PATH.
4350
4380
4351
4381
4352 Special syntax
4382 Directory management
4353 --------------
4383 --------------------
4354
4384
4355 Any lines which begin with '~', '/' and '.' will be executed as shell
4385 Since each command passed by ipython to the underlying system is executed
4356 commands instead of as Python code. The special escapes below are also
4386 in a subshell which exits immediately, you can NOT use !cd to navigate
4357 recognized. !cmd is valid in single or multi-line input, all others are
4387 the filesystem.
4358 only valid in single-line input::
4359
4388
4360 !cmd
4389 IPython provides its own builtin '%cd' magic command to move in the
4361 pass 'cmd' directly to the shell
4390 filesystem (the % is not required with automagic on). It also maintains
4362 !!cmd*
4391 a list of visited directories (use %dhist to see it) and allows direct
4363 execute 'cmd' and return output as a list (split on '\n')
4392 switching to any of them. Type 'cd?' for more details.
4364 var=!cmd
4365 capture output of cmd into var, as a string list
4366
4393
4367 A few brief examples will illustrate these (note that the indentation
4394 %pushd, %popd and %dirs are provided for directory stack handling.
4368 below may be incorrectly displayed)::
4369
4395
4370 fperez[~/test]|3> !ls *s.py
4371 scopes.py strings.py
4372
4396
4373 ls is an internal alias, so there's no need to use !::
4397 Enabled extensions
4398 ------------------
4374
4399
4375 fperez[~/test]|4> ls *s.py
4400 Some extensions, listed below, are enabled as default in this profile.
4376 scopes.py* strings.py
4377
4401
4378 !!ls will return the output into a Python variable FIXME!!!::
4402 envpersist
4403 ++++++++++
4379
4404
4380 fperez[~/test]|5> !!ls *s.py
4405 %env can be used to "remember" environment variable manipulations. Examples::
4381 <5> ['scopes.py', 'strings.py']
4382 fperez[~/test]|6> print _5
4383 ['scopes.py', 'strings.py']
4384
4406
4385 $ and $$ allow direct capture to named variables:
4407 %env - Show all environment variables
4408 %env VISUAL=jed - set VISUAL to jed
4409 %env PATH+=;/foo - append ;foo to PATH
4410 %env PATH+=;/bar - also append ;bar to PATH
4411 %env PATH-=/wbin; - prepend /wbin; to PATH
4412 %env -d VISUAL - forget VISUAL persistent val
4413 %env -p - print all persistent env modifications
4386
4414
4387 fperez[~/test]|7> $astr = ls *s.py
4415 ipy_which
4388 fperez[~/test]|8> astr
4416 +++++++++
4389 <8> 'scopes.py\nstrings.py'
4390
4417
4391 fperez[~/test]|9> $$alist = ls *s.py
4418 %which magic command. Like 'which' in unix, but knows about ipython aliases.
4392 fperez[~/test]|10> alist
4393 <10> ['scopes.py', 'strings.py']
4394
4419
4395 alist is now a normal python list you can loop over. Using $ will expand
4420 Example::
4396 back the python values when alias calls are made:
4397
4421
4398 fperez[~/test]|11> for f in alist:
4422 [C:/ipython]|14> %which st
4399 |..> print 'file',f,
4423 st -> start .
4400 |..> wc -l $f
4424 [C:/ipython]|15> %which d
4401 |..>
4425 d -> dir /w /og /on
4402 file scopes.py 13 scopes.py
4426 [C:/ipython]|16> %which cp
4403 file strings.py 4 strings.py
4427 cp -> cp
4428 == c:\bin\cp.exe
4429 c:\bin\cp.exe
4404
4430
4405 Note that you may need to protect your variables with braces if you want
4431 ipy_app_completers
4406 to append strings to their names. To copy all files in alist to .bak
4432 ++++++++++++++++++
4407 extensions, you must use::
4408
4433
4409 fperez[~/test]|12> for f in alist:
4434 Custom tab completers for some apps like svn, hg, bzr, apt-get. Try 'apt-get install <TAB>' in debian/ubuntu.
4410 |..> cp $f ${f}.bak
4411
4435
4412 If you try using $f.bak, you'll get an AttributeError exception saying
4436 ipy_rehashdir
4413 that your string object doesn't have a .bak attribute. This is because
4437 +++++++++++++
4414 the $ expansion mechanism allows you to expand full Python expressions::
4415
4438
4416 fperez[~/test]|13> echo "sys.platform is: $sys.platform"
4439 Allows you to add system command aliases for commands that are not along your path. Let's say that you just installed Putty and want to be able to invoke it without adding it to path, you can create the alias for it with rehashdir::
4417 sys.platform is: linux2
4418
4440
4419 IPython's input history handling is still active, which allows you to
4441 [~]|22> cd c:/opt/PuTTY/
4420 rerun a single block of multi-line input by simply using exec::
4442 [c:opt/PuTTY]|23> rehashdir .
4443 <23> ['pageant', 'plink', 'pscp', 'psftp', 'putty', 'puttygen', 'unins000']
4421
4444
4422 fperez[~/test]|14> $$alist = ls *.eps
4445 Now, you can execute any of those commams directly::
4423 fperez[~/test]|15> exec _i11
4424 file image2.eps 921 image2.eps
4425 file image.eps 921 image.eps
4426
4446
4427 While these are new special-case syntaxes, they are designed to allow
4447 [c:opt/PuTTY]|24> cd
4428 very efficient use of the shell with minimal typing. At an interactive
4448 [~]|25> putty
4429 shell prompt, conciseness of expression wins over readability.
4430
4449
4450 (the putty window opens).
4431
4451
4432 Useful functions and modules
4452 If you want to store the alias so that it will always be available, do '%store putty'. If you want to %store all these aliases persistently, just do it in a for loop::
4433 ----------------------------
4434
4453
4435 The os, sys and shutil modules from the Python standard library are
4454 [~]|27> for a in _23:
4436 automatically loaded. Some additional functions, useful for shell usage,
4455 |..> %store $a
4437 are listed below. You can request more help about them with '?'.
4456 |..>
4457 |..>
4458 Alias stored: pageant (0, 'c:\\opt\\PuTTY\\pageant.exe')
4459 Alias stored: plink (0, 'c:\\opt\\PuTTY\\plink.exe')
4460 Alias stored: pscp (0, 'c:\\opt\\PuTTY\\pscp.exe')
4461 Alias stored: psftp (0, 'c:\\opt\\PuTTY\\psftp.exe')
4462 ...
4438
4463
4439 *shell*
4464 mglob
4440 - execute a command in the underlying system shell
4465 +++++
4441 *system*
4442 - like shell(), but return the exit status of the command
4443 *sout*
4444 - capture the output of a command as a string
4445 *lout*
4446 - capture the output of a command as a list (split on '\n')
4447 *getoutputerror*
4448 - capture (output,error) of a shell commandss
4449
4466
4450 sout/lout are the functional equivalents of $/$$. They are provided to
4467 Provide the magic function %mglob, which makes it easier (than the 'find' command) to collect (possibly recursive) file lists. Examples::
4451 allow you to capture system output in the middle of true python code,
4452 function definitions, etc (where $ and $$ are invalid).
4453
4468
4469 [c:/ipython]|9> mglob *.py
4470 [c:/ipython]|10> mglob *.py rec:*.txt
4471 [c:/ipython]|19> workfiles = %mglob !.svn/ !.hg/ !*_Data/ !*.bak rec:.
4454
4472
4455 Directory management
4473 Note that the first 2 calls will put the file list in result history (_, _9, _10), and the last one will assign it to 'workfiles'.
4456 --------------------
4457
4474
4458 Since each command passed by pysh to the underlying system is executed
4459 in a subshell which exits immediately, you can NOT use !cd to navigate
4460 the filesystem.
4461
4475
4462 Pysh provides its own builtin '%cd' magic command to move in the
4463 filesystem (the % is not required with automagic on). It also maintains
4464 a list of visited directories (use %dhist to see it) and allows direct
4465 switching to any of them. Type 'cd?' for more details.
4466
4476
4467 %pushd, %popd and %dirs are provided for directory stack handling.
4468
4477
4469
4478
4470 Prompt customization
4479 Prompt customization
4471 --------------------
4480 --------------------
4472
4481
4473 The supplied ipy_profile_sh.py profile comes with an example of a very
4482 The supplied ipy_profile_sh.py profile comes with an example of a very
4474 colored and detailed prompt, mainly to serve as an illustration. The
4483 colored and detailed prompt, mainly to serve as an illustration. The
4475 valid escape sequences, besides color names, are:
4484 valid escape sequences, besides color names, are::
4476
4485
4477 *\#*
4486 \#
4478 - Prompt number, wrapped in the color escapes for the input prompt
4487 - Prompt number, wrapped in the color escapes for the input prompt
4479 (determined by the current color scheme).
4488 (determined by the current color scheme).
4480 *\N*
4489 \N
4481 - Just the prompt counter number, without any coloring wrappers. You
4490 - Just the prompt counter number, without any coloring wrappers. You
4482 can thus customize the actual prompt colors manually.
4491 can thus customize the actual prompt colors manually.
4483 *\D*
4492 \D
4484 - Dots, as many as there are digits in \# (so they align).
4493 - Dots, as many as there are digits in \# (so they align).
4485 *\w*
4494 \w
4486 - Current working directory (cwd).
4495 - Current working directory (cwd).
4487 *\W*
4496 \W
4488 - Basename of current working directory.
4497 - Basename of current working directory.
4489 *\XN*
4498 \XN
4490 - Where N=0..5. N terms of the cwd, with $HOME written as ~.
4499 - Where N=0..5. N terms of the cwd, with $HOME written as ~.
4491 *\YN*
4500 \YN
4492 - Where N=0..5. Like XN, but if ~ is term N+1 it's also shown.
4501 - Where N=0..5. Like XN, but if ~ is term N+1 it's also shown.
4493 *\u*
4502 \u
4494 - Username.
4503 - Username.
4495 *\H*
4504 \H
4496 - Full hostname.
4505 - Full hostname.
4497 *\h*
4506 \h
4498 - Hostname up to first '.'
4507 - Hostname up to first '.'
4499 *\$*
4508 \$
4500 - Root symbol ($ or #).
4509 - Root symbol ($ or #).
4501 *\t*
4510 \t
4502 - Current time, in H:M:S format.
4511 - Current time, in H:M:S format.
4503 *\v*
4512 \v
4504 - IPython release version.
4513 - IPython release version.
4505 *\n*
4514 \n
4506 - Newline.
4515 - Newline.
4507 *\r*
4516 \r
4508 - Carriage return.
4517 - Carriage return.
4509 *\\*
4518 \\
4510 - An explicitly escaped '\'.
4519 - An explicitly escaped '\'.
4511
4520
4512 You can configure your prompt colors using any ANSI color escape. Each
4521 You can configure your prompt colors using any ANSI color escape. Each
4513 color escape sets the color for any subsequent text, until another
4522 color escape sets the color for any subsequent text, until another
4514 escape comes in and changes things. The valid color escapes are:
4523 escape comes in and changes things. The valid color escapes are::
4515
4524
4516 *\C_Black*
4525 \C_Black
4517
4526 \C_Blue
4518 *\C_Blue*
4527 \C_Brown
4519
4528 \C_Cyan
4520 *\C_Brown*
4529 \C_DarkGray
4521
4530 \C_Green
4522 *\C_Cyan*
4531 \C_LightBlue
4523
4532 \C_LightCyan
4524 *\C_DarkGray*
4533 \C_LightGray
4525
4534 \C_LightGreen
4526 *\C_Green*
4535 \C_LightPurple
4527
4536 \C_LightRed
4528 *\C_LightBlue*
4537 \C_Purple
4529
4538 \C_Red
4530 *\C_LightCyan*
4539 \C_White
4531
4540 \C_Yellow
4532 *\C_LightGray*
4541 \C_Normal
4533
4534 *\C_LightGreen*
4535
4536 *\C_LightPurple*
4537
4538 *\C_LightRed*
4539
4540 *\C_Purple*
4541
4542 *\C_Red*
4543
4544 *\C_White*
4545
4546 *\C_Yellow*
4547
4548 *\C_Normal*
4549 Stop coloring, defaults to your terminal settings.
4542 Stop coloring, defaults to your terminal settings.
4550
4543
4551 Threading support
4544 Threading support
4552 =================
4545 =================
4553
4546
4554 WARNING: The threading support is still somewhat experimental, and it
4547 WARNING: The threading support is still somewhat experimental, and it
4555 has only seen reasonable testing under Linux. Threaded code is
4548 has only seen reasonable testing under Linux. Threaded code is
4556 particularly tricky to debug, and it tends to show extremely
4549 particularly tricky to debug, and it tends to show extremely
4557 platform-dependent behavior. Since I only have access to Linux machines,
4550 platform-dependent behavior. Since I only have access to Linux machines,
4558 I will have to rely on user's experiences and assistance for this area
4551 I will have to rely on user's experiences and assistance for this area
4559 of IPython to improve under other platforms.
4552 of IPython to improve under other platforms.
4560
4553
4561 IPython, via the -gthread , -qthread, -q4thread and -wthread options
4554 IPython, via the -gthread , -qthread, -q4thread and -wthread options
4562 (described in Sec. 5.1 <node5.html#sec:threading-opts>), can run in
4555 (described in Sec. 5.1 <node5.html#sec:threading-opts>), can run in
4563 multithreaded mode to support pyGTK, Qt3, Qt4 and WXPython applications
4556 multithreaded mode to support pyGTK, Qt3, Qt4 and WXPython applications
4564 respectively. These GUI toolkits need to control the python main loop of
4557 respectively. These GUI toolkits need to control the python main loop of
4565 execution, so under a normal Python interpreter, starting a pyGTK, Qt3,
4558 execution, so under a normal Python interpreter, starting a pyGTK, Qt3,
4566 Qt4 or WXPython application will immediately freeze the shell.
4559 Qt4 or WXPython application will immediately freeze the shell.
4567
4560
4568 IPython, with one of these options (you can only use one at a time),
4561 IPython, with one of these options (you can only use one at a time),
4569 separates the graphical loop and IPython's code execution run into
4562 separates the graphical loop and IPython's code execution run into
4570 different threads. This allows you to test interactively (with %run, for
4563 different threads. This allows you to test interactively (with %run, for
4571 example) your GUI code without blocking.
4564 example) your GUI code without blocking.
4572
4565
4573 A nice mini-tutorial on using IPython along with the Qt Designer
4566 A nice mini-tutorial on using IPython along with the Qt Designer
4574 application is available at the SciPy wiki:
4567 application is available at the SciPy wiki:
4575 http://www.scipy.org/Cookbook/Matplotlib/Qt_with_IPython_and_Designer.
4568 http://www.scipy.org/Cookbook/Matplotlib/Qt_with_IPython_and_Designer.
4576
4569
4577
4570
4578 Tk issues
4571 Tk issues
4579 ---------
4572 ---------
4580
4573
4581 As indicated in Sec. 5.1 <node5.html#sec:threading-opts>, a special -tk
4574 As indicated in Sec. 5.1 <node5.html#sec:threading-opts>, a special -tk
4582 option is provided to try and allow Tk graphical applications to coexist
4575 option is provided to try and allow Tk graphical applications to coexist
4583 interactively with WX, Qt or GTK ones. Whether this works at all,
4576 interactively with WX, Qt or GTK ones. Whether this works at all,
4584 however, is very platform and configuration dependent. Please experiment
4577 however, is very platform and configuration dependent. Please experiment
4585 with simple test cases before committing to using this combination of Tk
4578 with simple test cases before committing to using this combination of Tk
4586 and GTK/Qt/WX threading in a production environment.
4579 and GTK/Qt/WX threading in a production environment.
4587
4580
4588
4581
4589 I/O pitfalls
4582 I/O pitfalls
4590 ------------
4583 ------------
4591
4584
4592 Be mindful that the Python interpreter switches between threads every
4585 Be mindful that the Python interpreter switches between threads every
4593 $N$ bytecodes, where the default value as of Python 2.3 is $N=100.$ This
4586 $N$ bytecodes, where the default value as of Python 2.3 is $N=100.$ This
4594 value can be read by using the sys.getcheckinterval() function, and it
4587 value can be read by using the sys.getcheckinterval() function, and it
4595 can be reset via sys.setcheckinterval(N). This switching of threads can
4588 can be reset via sys.setcheckinterval(N). This switching of threads can
4596 cause subtly confusing effects if one of your threads is doing file I/O.
4589 cause subtly confusing effects if one of your threads is doing file I/O.
4597 In text mode, most systems only flush file buffers when they encounter a
4590 In text mode, most systems only flush file buffers when they encounter a
4598 '\n'. An instruction as simple as::
4591 '\n'. An instruction as simple as::
4599
4592
4600 print >> filehandle, ''hello world''
4593 print >> filehandle, ''hello world''
4601
4594
4602 actually consists of several bytecodes, so it is possible that the
4595 actually consists of several bytecodes, so it is possible that the
4603 newline does not reach your file before the next thread switch.
4596 newline does not reach your file before the next thread switch.
4604 Similarly, if you are writing to a file in binary mode, the file won't
4597 Similarly, if you are writing to a file in binary mode, the file won't
4605 be flushed until the buffer fills, and your other thread may see
4598 be flushed until the buffer fills, and your other thread may see
4606 apparently truncated files.
4599 apparently truncated files.
4607
4600
4608 For this reason, if you are using IPython's thread support and have (for
4601 For this reason, if you are using IPython's thread support and have (for
4609 example) a GUI application which will read data generated by files
4602 example) a GUI application which will read data generated by files
4610 written to from the IPython thread, the safest approach is to open all
4603 written to from the IPython thread, the safest approach is to open all
4611 of your files in unbuffered mode (the third argument to the file/open
4604 of your files in unbuffered mode (the third argument to the file/open
4612 function is the buffering value)::
4605 function is the buffering value)::
4613
4606
4614 filehandle = open(filename,mode,0)
4607 filehandle = open(filename,mode,0)
4615
4608
4616 This is obviously a brute force way of avoiding race conditions with the
4609 This is obviously a brute force way of avoiding race conditions with the
4617 file buffering. If you want to do it cleanly, and you have a resource
4610 file buffering. If you want to do it cleanly, and you have a resource
4618 which is being shared by the interactive IPython loop and your GUI
4611 which is being shared by the interactive IPython loop and your GUI
4619 thread, you should really handle it with thread locking and
4612 thread, you should really handle it with thread locking and
4620 syncrhonization properties. The Python documentation discusses these.
4613 syncrhonization properties. The Python documentation discusses these.
4621
4614
4622 Interactive demos with IPython
4615 Interactive demos with IPython
4623 ==============================
4616 ==============================
4624
4617
4625 IPython ships with a basic system for running scripts interactively in
4618 IPython ships with a basic system for running scripts interactively in
4626 sections, useful when presenting code to audiences. A few tags embedded
4619 sections, useful when presenting code to audiences. A few tags embedded
4627 in comments (so that the script remains valid Python code) divide a file
4620 in comments (so that the script remains valid Python code) divide a file
4628 into separate blocks, and the demo can be run one block at a time, with
4621 into separate blocks, and the demo can be run one block at a time, with
4629 IPython printing (with syntax highlighting) the block before executing
4622 IPython printing (with syntax highlighting) the block before executing
4630 it, and returning to the interactive prompt after each block. The
4623 it, and returning to the interactive prompt after each block. The
4631 interactive namespace is updated after each block is run with the
4624 interactive namespace is updated after each block is run with the
4632 contents of the demo's namespace.
4625 contents of the demo's namespace.
4633
4626
4634 This allows you to show a piece of code, run it and then execute
4627 This allows you to show a piece of code, run it and then execute
4635 interactively commands based on the variables just created. Once you
4628 interactively commands based on the variables just created. Once you
4636 want to continue, you simply execute the next block of the demo. The
4629 want to continue, you simply execute the next block of the demo. The
4637 following listing shows the markup necessary for dividing a script into
4630 following listing shows the markup necessary for dividing a script into
4638 sections for execution as a demo::
4631 sections for execution as a demo::
4639
4632
4640
4633
4641 """A simple interactive demo to illustrate the use of IPython's Demo class.
4634 """A simple interactive demo to illustrate the use of IPython's Demo class.
4642
4635
4643 Any python script can be run as a demo, but that does little more than showing
4636 Any python script can be run as a demo, but that does little more than showing
4644 it on-screen, syntax-highlighted in one shot. If you add a little simple
4637 it on-screen, syntax-highlighted in one shot. If you add a little simple
4645 markup, you can stop at specified intervals and return to the ipython prompt,
4638 markup, you can stop at specified intervals and return to the ipython prompt,
4646 resuming execution later.
4639 resuming execution later.
4647 """
4640 """
4648
4641
4649 print 'Hello, welcome to an interactive IPython demo.'
4642 print 'Hello, welcome to an interactive IPython demo.'
4650 print 'Executing this block should require confirmation before proceeding,'
4643 print 'Executing this block should require confirmation before proceeding,'
4651 print 'unless auto_all has been set to true in the demo object'
4644 print 'unless auto_all has been set to true in the demo object'
4652
4645
4653 # The mark below defines a block boundary, which is a point where IPython will
4646 # The mark below defines a block boundary, which is a point where IPython will
4654 # stop execution and return to the interactive prompt.
4647 # stop execution and return to the interactive prompt.
4655 # Note that in actual interactive execution,
4648 # Note that in actual interactive execution,
4656 # <demo> --- stop ---
4649 # <demo> --- stop ---
4657
4650
4658 x = 1
4651 x = 1
4659 y = 2
4652 y = 2
4660
4653
4661 # <demo> --- stop ---
4654 # <demo> --- stop ---
4662
4655
4663 # the mark below makes this block as silent
4656 # the mark below makes this block as silent
4664 # <demo> silent
4657 # <demo> silent
4665
4658
4666 print 'This is a silent block, which gets executed but not printed.'
4659 print 'This is a silent block, which gets executed but not printed.'
4667
4660
4668 # <demo> --- stop ---
4661 # <demo> --- stop ---
4669 # <demo> auto
4662 # <demo> auto
4670 print 'This is an automatic block.'
4663 print 'This is an automatic block.'
4671 print 'It is executed without asking for confirmation, but printed.'
4664 print 'It is executed without asking for confirmation, but printed.'
4672 z = x+y
4665 z = x+y
4673
4666
4674 print 'z=',x
4667 print 'z=',x
4675
4668
4676 # <demo> --- stop ---
4669 # <demo> --- stop ---
4677 # This is just another normal block.
4670 # This is just another normal block.
4678 print 'z is now:', z
4671 print 'z is now:', z
4679
4672
4680 print 'bye!'
4673 print 'bye!'
4681
4674
4682 In order to run a file as a demo, you must first make a Demo object out
4675 In order to run a file as a demo, you must first make a Demo object out
4683 of it. If the file is named myscript.py, the following code will make a
4676 of it. If the file is named myscript.py, the following code will make a
4684 demo::
4677 demo::
4685
4678
4686 from IPython.demo import Demo
4679 from IPython.demo import Demo
4687
4680
4688 mydemo = Demo('myscript.py')
4681 mydemo = Demo('myscript.py')
4689
4682
4690 This creates the mydemo object, whose blocks you run one at a time by
4683 This creates the mydemo object, whose blocks you run one at a time by
4691 simply calling the object with no arguments. If you have autocall active
4684 simply calling the object with no arguments. If you have autocall active
4692 in IPython (the default), all you need to do is type::
4685 in IPython (the default), all you need to do is type::
4693
4686
4694 mydemo
4687 mydemo
4695
4688
4696 and IPython will call it, executing each block. Demo objects can be
4689 and IPython will call it, executing each block. Demo objects can be
4697 restarted, you can move forward or back skipping blocks, re-execute the
4690 restarted, you can move forward or back skipping blocks, re-execute the
4698 last block, etc. Simply use the Tab key on a demo object to see its
4691 last block, etc. Simply use the Tab key on a demo object to see its
4699 methods, and call '?' on them to see their docstrings for more usage
4692 methods, and call '?' on them to see their docstrings for more usage
4700 details. In addition, the demo module itself contains a comprehensive
4693 details. In addition, the demo module itself contains a comprehensive
4701 docstring, which you can access via::
4694 docstring, which you can access via::
4702
4695
4703 from IPython import demo
4696 from IPython import demo
4704
4697
4705 demo?
4698 demo?
4706
4699
4707 Limitations: It is important to note that these demos are limited to
4700 Limitations: It is important to note that these demos are limited to
4708 fairly simple uses. In particular, you can not put division marks in
4701 fairly simple uses. In particular, you can not put division marks in
4709 indented code (loops, if statements, function definitions, etc.)
4702 indented code (loops, if statements, function definitions, etc.)
4710 Supporting something like this would basically require tracking the
4703 Supporting something like this would basically require tracking the
4711 internal execution state of the Python interpreter, so only top-level
4704 internal execution state of the Python interpreter, so only top-level
4712 divisions are allowed. If you want to be able to open an IPython
4705 divisions are allowed. If you want to be able to open an IPython
4713 instance at an arbitrary point in a program, you can use IPython's
4706 instance at an arbitrary point in a program, you can use IPython's
4714 embedding facilities, described in detail in Sec. 9
4707 embedding facilities, described in detail in Sec. 9
4715
4708
4716
4709
4717 Plotting with matplotlib
4710 Plotting with matplotlib
4718 ========================
4711 ========================
4719
4712
4720 The matplotlib library (http://matplotlib.sourceforge.net
4713 The matplotlib library (http://matplotlib.sourceforge.net
4721 http://matplotlib.sourceforge.net) provides high quality 2D plotting for
4714 http://matplotlib.sourceforge.net) provides high quality 2D plotting for
4722 Python. Matplotlib can produce plots on screen using a variety of GUI
4715 Python. Matplotlib can produce plots on screen using a variety of GUI
4723 toolkits, including Tk, GTK and WXPython. It also provides a number of
4716 toolkits, including Tk, GTK and WXPython. It also provides a number of
4724 commands useful for scientific computing, all with a syntax compatible
4717 commands useful for scientific computing, all with a syntax compatible
4725 with that of the popular Matlab program.
4718 with that of the popular Matlab program.
4726
4719
4727 IPython accepts the special option -pylab (Sec. 5.2
4720 IPython accepts the special option -pylab (Sec. 5.2
4728 <node5.html#sec:cmd-line-opts>). This configures it to support
4721 <node5.html#sec:cmd-line-opts>). This configures it to support
4729 matplotlib, honoring the settings in the .matplotlibrc file. IPython
4722 matplotlib, honoring the settings in the .matplotlibrc file. IPython
4730 will detect the user's choice of matplotlib GUI backend, and
4723 will detect the user's choice of matplotlib GUI backend, and
4731 automatically select the proper threading model to prevent blocking. It
4724 automatically select the proper threading model to prevent blocking. It
4732 also sets matplotlib in interactive mode and modifies %run slightly, so
4725 also sets matplotlib in interactive mode and modifies %run slightly, so
4733 that any matplotlib-based script can be executed using %run and the
4726 that any matplotlib-based script can be executed using %run and the
4734 final show() command does not block the interactive shell.
4727 final show() command does not block the interactive shell.
4735
4728
4736 The -pylab option must be given first in order for IPython to configure
4729 The -pylab option must be given first in order for IPython to configure
4737 its threading mode. However, you can still issue other options
4730 its threading mode. However, you can still issue other options
4738 afterwards. This allows you to have a matplotlib-based environment
4731 afterwards. This allows you to have a matplotlib-based environment
4739 customized with additional modules using the standard IPython profile
4732 customized with additional modules using the standard IPython profile
4740 mechanism (Sec. 7.3 <node7.html#sec:profiles>): ''ipython -pylab -p
4733 mechanism (Sec. 7.3 <node7.html#sec:profiles>): ''ipython -pylab -p
4741 myprofile'' will load the profile defined in ipythonrc-myprofile after
4734 myprofile'' will load the profile defined in ipythonrc-myprofile after
4742 configuring matplotlib.
4735 configuring matplotlib.
4743
4736
4744 Reporting bugs
4737 Reporting bugs
4745 ==============
4738 ==============
4746
4739
4747 Automatic crash reports
4740 Automatic crash reports
4748 -----------------------
4741 -----------------------
4749
4742
4750 Ideally, IPython itself shouldn't crash. It will catch exceptions
4743 Ideally, IPython itself shouldn't crash. It will catch exceptions
4751 produced by you, but bugs in its internals will still crash it.
4744 produced by you, but bugs in its internals will still crash it.
4752
4745
4753 In such a situation, IPython will leave a file named
4746 In such a situation, IPython will leave a file named
4754 IPython_crash_report.txt in your IPYTHONDIR directory (that way if
4747 IPython_crash_report.txt in your IPYTHONDIR directory (that way if
4755 crashes happen several times it won't litter many directories, the
4748 crashes happen several times it won't litter many directories, the
4756 post-mortem file is always located in the same place and new occurrences
4749 post-mortem file is always located in the same place and new occurrences
4757 just overwrite the previous one). If you can mail this file to the
4750 just overwrite the previous one). If you can mail this file to the
4758 developers (see sec. 20 <node20.html#sec:credits> for names and
4751 developers (see sec. 20 <node20.html#sec:credits> for names and
4759 addresses), it will help us a lot in understanding the cause of the
4752 addresses), it will help us a lot in understanding the cause of the
4760 problem and fixing it sooner.
4753 problem and fixing it sooner.
4761
4754
4762
4755
4763 The bug tracker
4756 The bug tracker
4764 ---------------
4757 ---------------
4765
4758
4766 IPython also has an online bug-tracker, located at
4759 IPython also has an online bug-tracker, located at
4767 http://projects.scipy.org/ipython/ipython/report/1. In addition to
4760 http://projects.scipy.org/ipython/ipython/report/1. In addition to
4768 mailing the developers, it would be a good idea to file a bug report
4761 mailing the developers, it would be a good idea to file a bug report
4769 here. This will ensure that the issue is properly followed to
4762 here. This will ensure that the issue is properly followed to
4770 conclusion. To report new bugs you will have to register first.
4763 conclusion. To report new bugs you will have to register first.
4771
4764
4772 You can also use this bug tracker to file feature requests.
4765 You can also use this bug tracker to file feature requests.
4773
4766
4774 Brief history
4767 Brief history
4775 =============
4768 =============
4776
4769
4777
4770
4778 Origins
4771 Origins
4779
4772
4780 The current IPython system grew out of the following three projects:
4773 The current IPython system grew out of the following three projects:
4781
4774
4782 * [ipython] by Fernando Pérez. I was working on adding
4775 * [ipython] by Fernando Pérez. I was working on adding
4783 Mathematica-type prompts and a flexible configuration system
4776 Mathematica-type prompts and a flexible configuration system
4784 (something better than $PYTHONSTARTUP) to the standard Python
4777 (something better than $PYTHONSTARTUP) to the standard Python
4785 interactive interpreter.
4778 interactive interpreter.
4786 * [IPP] by Janko Hauser. Very well organized, great usability. Had
4779 * [IPP] by Janko Hauser. Very well organized, great usability. Had
4787 an old help system. IPP was used as the 'container' code into
4780 an old help system. IPP was used as the 'container' code into
4788 which I added the functionality from ipython and LazyPython.
4781 which I added the functionality from ipython and LazyPython.
4789 * [LazyPython] by Nathan Gray. Simple but very powerful. The quick
4782 * [LazyPython] by Nathan Gray. Simple but very powerful. The quick
4790 syntax (auto parens, auto quotes) and verbose/colored tracebacks
4783 syntax (auto parens, auto quotes) and verbose/colored tracebacks
4791 were all taken from here.
4784 were all taken from here.
4792
4785
4793 When I found out (see sec. 20 <node20.html#figgins>) about IPP and
4786 When I found out (see sec. 20 <node20.html#figgins>) about IPP and
4794 LazyPython I tried to join all three into a unified system. I thought
4787 LazyPython I tried to join all three into a unified system. I thought
4795 this could provide a very nice working environment, both for regular
4788 this could provide a very nice working environment, both for regular
4796 programming and scientific computing: shell-like features, IDL/Matlab
4789 programming and scientific computing: shell-like features, IDL/Matlab
4797 numerics, Mathematica-type prompt history and great object introspection
4790 numerics, Mathematica-type prompt history and great object introspection
4798 and help facilities. I think it worked reasonably well, though it was a
4791 and help facilities. I think it worked reasonably well, though it was a
4799 lot more work than I had initially planned.
4792 lot more work than I had initially planned.
4800
4793
4801
4794
4802 Current status
4795 Current status
4803 --------------
4796 --------------
4804
4797
4805 The above listed features work, and quite well for the most part. But
4798 The above listed features work, and quite well for the most part. But
4806 until a major internal restructuring is done (see below), only bug
4799 until a major internal restructuring is done (see below), only bug
4807 fixing will be done, no other features will be added (unless very minor
4800 fixing will be done, no other features will be added (unless very minor
4808 and well localized in the cleaner parts of the code).
4801 and well localized in the cleaner parts of the code).
4809
4802
4810 IPython consists of some 18000 lines of pure python code, of which
4803 IPython consists of some 18000 lines of pure python code, of which
4811 roughly two thirds is reasonably clean. The rest is, messy code which
4804 roughly two thirds is reasonably clean. The rest is, messy code which
4812 needs a massive restructuring before any further major work is done.
4805 needs a massive restructuring before any further major work is done.
4813 Even the messy code is fairly well documented though, and most of the
4806 Even the messy code is fairly well documented though, and most of the
4814 problems in the (non-existent) class design are well pointed to by a
4807 problems in the (non-existent) class design are well pointed to by a
4815 PyChecker run. So the rewriting work isn't that bad, it will just be
4808 PyChecker run. So the rewriting work isn't that bad, it will just be
4816 time-consuming.
4809 time-consuming.
4817
4810
4818
4811
4819 Future
4812 Future
4820 ------
4813 ------
4821
4814
4822 See the separate new_design document for details. Ultimately, I would
4815 See the separate new_design document for details. Ultimately, I would
4823 like to see IPython become part of the standard Python distribution as a
4816 like to see IPython become part of the standard Python distribution as a
4824 'big brother with batteries' to the standard Python interactive
4817 'big brother with batteries' to the standard Python interactive
4825 interpreter. But that will never happen with the current state of the
4818 interpreter. But that will never happen with the current state of the
4826 code, so all contributions are welcome.
4819 code, so all contributions are welcome.
4827
4820
4828 License
4821 License
4829 =======
4822 =======
4830
4823
4831 IPython is released under the terms of the BSD license, whose general
4824 IPython is released under the terms of the BSD license, whose general
4832 form can be found at:
4825 form can be found at:
4833 http://www.opensource.org/licenses/bsd-license.php. The full text of the
4826 http://www.opensource.org/licenses/bsd-license.php. The full text of the
4834 IPython license is reproduced below::
4827 IPython license is reproduced below::
4835
4828
4836 IPython is released under a BSD-type license.
4829 IPython is released under a BSD-type license.
4837
4830
4838 Copyright (c) 2001, 2002, 2003, 2004 Fernando Perez
4831 Copyright (c) 2001, 2002, 2003, 2004 Fernando Perez
4839 <fperez@colorado.edu>.
4832 <fperez@colorado.edu>.
4840
4833
4841 Copyright (c) 2001 Janko Hauser <jhauser@zscout.de> and
4834 Copyright (c) 2001 Janko Hauser <jhauser@zscout.de> and
4842 Nathaniel Gray <n8gray@caltech.edu>.
4835 Nathaniel Gray <n8gray@caltech.edu>.
4843
4836
4844 All rights reserved.
4837 All rights reserved.
4845
4838
4846 Redistribution and use in source and binary forms, with or without
4839 Redistribution and use in source and binary forms, with or without
4847 modification, are permitted provided that the following conditions
4840 modification, are permitted provided that the following conditions
4848 are met:
4841 are met:
4849
4842
4850 a. Redistributions of source code must retain the above copyright
4843 a. Redistributions of source code must retain the above copyright
4851 notice, this list of conditions and the following disclaimer.
4844 notice, this list of conditions and the following disclaimer.
4852
4845
4853 b. Redistributions in binary form must reproduce the above copyright
4846 b. Redistributions in binary form must reproduce the above copyright
4854 notice, this list of conditions and the following disclaimer in the
4847 notice, this list of conditions and the following disclaimer in the
4855 documentation and/or other materials provided with the distribution.
4848 documentation and/or other materials provided with the distribution.
4856
4849
4857 c. Neither the name of the copyright holders nor the names of any
4850 c. Neither the name of the copyright holders nor the names of any
4858 contributors to this software may be used to endorse or promote
4851 contributors to this software may be used to endorse or promote
4859 products derived from this software without specific prior written
4852 products derived from this software without specific prior written
4860 permission.
4853 permission.
4861
4854
4862 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4855 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4863 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
4856 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
4864 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
4857 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
4865 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
4858 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
4866 REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
4859 REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
4867 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
4860 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
4868 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
4861 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
4869 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
4862 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
4870 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
4863 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
4871 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
4864 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
4872 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
4865 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
4873 POSSIBILITY OF SUCH DAMAGE.
4866 POSSIBILITY OF SUCH DAMAGE.
4874
4867
4875 Individual authors are the holders of the copyright for their code and
4868 Individual authors are the holders of the copyright for their code and
4876 are listed in each file.
4869 are listed in each file.
4877
4870
4878 Some files (DPyGetOpt.py, for example) may be licensed under different
4871 Some files (DPyGetOpt.py, for example) may be licensed under different
4879 conditions. Ultimately each file indicates clearly the conditions under
4872 conditions. Ultimately each file indicates clearly the conditions under
4880 which its author/authors have decided to publish the code.
4873 which its author/authors have decided to publish the code.
4881
4874
4882 Versions of IPython up to and including 0.6.3 were released under the
4875 Versions of IPython up to and including 0.6.3 were released under the
4883 GNU Lesser General Public License (LGPL), available at
4876 GNU Lesser General Public License (LGPL), available at
4884 http://www.gnu.org/copyleft/lesser.html.
4877 http://www.gnu.org/copyleft/lesser.html.
4885
4878
4886 Credits
4879 Credits
4887 =======
4880 =======
4888
4881
4889 IPython is mainly developed by Fernando Pérez
4882 IPython is mainly developed by Fernando Pérez
4890 <Fernando.Perez@colorado.edu>, but the project was born from mixing in
4883 <Fernando.Perez@colorado.edu>, but the project was born from mixing in
4891 Fernando's code with the IPP project by Janko Hauser
4884 Fernando's code with the IPP project by Janko Hauser
4892 <jhauser-AT-zscout.de> and LazyPython by Nathan Gray
4885 <jhauser-AT-zscout.de> and LazyPython by Nathan Gray
4893 <n8gray-AT-caltech.edu>. For all IPython-related requests, please
4886 <n8gray-AT-caltech.edu>. For all IPython-related requests, please
4894 contact Fernando.
4887 contact Fernando.
4895
4888
4896 As of early 2006, the following developers have joined the core team:
4889 As of early 2006, the following developers have joined the core team:
4897
4890
4898 * [Robert Kern] <rkern-AT-enthought.com>: co-mentored the 2005
4891 * [Robert Kern] <rkern-AT-enthought.com>: co-mentored the 2005
4899 Google Summer of Code project to develop python interactive
4892 Google Summer of Code project to develop python interactive
4900 notebooks (XML documents) and graphical interface. This project
4893 notebooks (XML documents) and graphical interface. This project
4901 was awarded to the students Tzanko Matev <tsanko-AT-gmail.com> and
4894 was awarded to the students Tzanko Matev <tsanko-AT-gmail.com> and
4902 Toni Alatalo <antont-AT-an.org>
4895 Toni Alatalo <antont-AT-an.org>
4903 * [Brian Granger] <bgranger-AT-scu.edu>: extending IPython to allow
4896 * [Brian Granger] <bgranger-AT-scu.edu>: extending IPython to allow
4904 support for interactive parallel computing.
4897 support for interactive parallel computing.
4905 * [Ville Vainio] <vivainio-AT-gmail.com>: Ville is the new
4898 * [Ville Vainio] <vivainio-AT-gmail.com>: Ville is the new
4906 maintainer for the main trunk of IPython after version 0.7.1.
4899 maintainer for the main trunk of IPython after version 0.7.1.
4907
4900
4908 User or development help should be requested via the IPython mailing lists:
4901 User or development help should be requested via the IPython mailing lists:
4909
4902
4910 *User list:*
4903 *User list:*
4911 http://scipy.net/mailman/listinfo/ipython-user
4904 http://scipy.net/mailman/listinfo/ipython-user
4912 *Developer's list:*
4905 *Developer's list:*
4913 http://scipy.net/mailman/listinfo/ipython-dev
4906 http://scipy.net/mailman/listinfo/ipython-dev
4914
4907
4915 The IPython project is also very grateful to^7 <footnode.html#foot2913>:
4908 The IPython project is also very grateful to^7 <footnode.html#foot2913>:
4916
4909
4917 Bill Bumgarner <bbum-AT-friday.com>: for providing the DPyGetOpt module
4910 Bill Bumgarner <bbum-AT-friday.com>: for providing the DPyGetOpt module
4918 which gives very powerful and convenient handling of command-line
4911 which gives very powerful and convenient handling of command-line
4919 options (light years ahead of what Python 2.1.1's getopt module does).
4912 options (light years ahead of what Python 2.1.1's getopt module does).
4920
4913
4921 Ka-Ping Yee <ping-AT-lfw.org>: for providing the Itpl module for
4914 Ka-Ping Yee <ping-AT-lfw.org>: for providing the Itpl module for
4922 convenient and powerful string interpolation with a much nicer syntax
4915 convenient and powerful string interpolation with a much nicer syntax
4923 than formatting through the '%' operator.
4916 than formatting through the '%' operator.
4924
4917
4925 Arnd Baecker <baecker-AT-physik.tu-dresden.de>: for his many very useful
4918 Arnd Baecker <baecker-AT-physik.tu-dresden.de>: for his many very useful
4926 suggestions and comments, and lots of help with testing and
4919 suggestions and comments, and lots of help with testing and
4927 documentation checking. Many of IPython's newer features are a result of
4920 documentation checking. Many of IPython's newer features are a result of
4928 discussions with him (bugs are still my fault, not his).
4921 discussions with him (bugs are still my fault, not his).
4929
4922
4930 Obviously Guido van Rossum and the whole Python development team, that
4923 Obviously Guido van Rossum and the whole Python development team, that
4931 goes without saying.
4924 goes without saying.
4932
4925
4933 IPython's website is generously hosted at http://ipython.scipy.orgby
4926 IPython's website is generously hosted at http://ipython.scipy.orgby
4934 Enthought (http://www.enthought.com). I am very grateful to them and all
4927 Enthought (http://www.enthought.com). I am very grateful to them and all
4935 of the SciPy team for their contribution.
4928 of the SciPy team for their contribution.
4936
4929
4937 Fernando would also like to thank Stephen Figgins <fig-AT-monitor.net>,
4930 Fernando would also like to thank Stephen Figgins <fig-AT-monitor.net>,
4938 an O'Reilly Python editor. His Oct/11/2001 article about IPP and
4931 an O'Reilly Python editor. His Oct/11/2001 article about IPP and
4939 LazyPython, was what got this project started. You can read it at:
4932 LazyPython, was what got this project started. You can read it at:
4940 http://www.onlamp.com/pub/a/python/2001/10/11/pythonnews.html.
4933 http://www.onlamp.com/pub/a/python/2001/10/11/pythonnews.html.
4941
4934
4942 And last but not least, all the kind IPython users who have emailed new
4935 And last but not least, all the kind IPython users who have emailed new
4943 code, bug reports, fixes, comments and ideas. A brief list follows,
4936 code, bug reports, fixes, comments and ideas. A brief list follows,
4944 please let me know if I have ommitted your name by accident:
4937 please let me know if I have ommitted your name by accident:
4945
4938
4946 * [Jack Moffit] <jack-AT-xiph.org> Bug fixes, including the infamous
4939 * [Jack Moffit] <jack-AT-xiph.org> Bug fixes, including the infamous
4947 color problem. This bug alone caused many lost hours and
4940 color problem. This bug alone caused many lost hours and
4948 frustration, many thanks to him for the fix. I've always been a
4941 frustration, many thanks to him for the fix. I've always been a
4949 fan of Ogg & friends, now I have one more reason to like these folks.
4942 fan of Ogg & friends, now I have one more reason to like these folks.
4950 Jack is also contributing with Debian packaging and many other
4943 Jack is also contributing with Debian packaging and many other
4951 things.
4944 things.
4952 * [Alexander Schmolck] <a.schmolck-AT-gmx.net> Emacs work, bug
4945 * [Alexander Schmolck] <a.schmolck-AT-gmx.net> Emacs work, bug
4953 reports, bug fixes, ideas, lots more. The ipython.el mode for
4946 reports, bug fixes, ideas, lots more. The ipython.el mode for
4954 (X)Emacs is Alex's code, providing full support for IPython under
4947 (X)Emacs is Alex's code, providing full support for IPython under
4955 (X)Emacs.
4948 (X)Emacs.
4956 * [Andrea Riciputi] <andrea.riciputi-AT-libero.it> Mac OSX
4949 * [Andrea Riciputi] <andrea.riciputi-AT-libero.it> Mac OSX
4957 information, Fink package management.
4950 information, Fink package management.
4958 * [Gary Bishop] <gb-AT-cs.unc.edu> Bug reports, and patches to work
4951 * [Gary Bishop] <gb-AT-cs.unc.edu> Bug reports, and patches to work
4959 around the exception handling idiosyncracies of WxPython. Readline
4952 around the exception handling idiosyncracies of WxPython. Readline
4960 and color support for Windows.
4953 and color support for Windows.
4961 * [Jeffrey Collins] <Jeff.Collins-AT-vexcel.com> Bug reports. Much
4954 * [Jeffrey Collins] <Jeff.Collins-AT-vexcel.com> Bug reports. Much
4962 improved readline support, including fixes for Python 2.3.
4955 improved readline support, including fixes for Python 2.3.
4963 * [Dryice Liu] <dryice-AT-liu.com.cn> FreeBSD port.
4956 * [Dryice Liu] <dryice-AT-liu.com.cn> FreeBSD port.
4964 * [Mike Heeter] <korora-AT-SDF.LONESTAR.ORG>
4957 * [Mike Heeter] <korora-AT-SDF.LONESTAR.ORG>
4965 * [Christopher Hart] <hart-AT-caltech.edu> PDB integration.
4958 * [Christopher Hart] <hart-AT-caltech.edu> PDB integration.
4966 * [Milan Zamazal] <pdm-AT-zamazal.org> Emacs info.
4959 * [Milan Zamazal] <pdm-AT-zamazal.org> Emacs info.
4967 * [Philip Hisley] <compsys-AT-starpower.net>
4960 * [Philip Hisley] <compsys-AT-starpower.net>
4968 * [Holger Krekel] <pyth-AT-devel.trillke.net> Tab completion, lots
4961 * [Holger Krekel] <pyth-AT-devel.trillke.net> Tab completion, lots
4969 more.
4962 more.
4970 * [Robin Siebler] <robinsiebler-AT-starband.net>
4963 * [Robin Siebler] <robinsiebler-AT-starband.net>
4971 * [Ralf Ahlbrink] <ralf_ahlbrink-AT-web.de>
4964 * [Ralf Ahlbrink] <ralf_ahlbrink-AT-web.de>
4972 * [Thorsten Kampe] <thorsten-AT-thorstenkampe.de>
4965 * [Thorsten Kampe] <thorsten-AT-thorstenkampe.de>
4973 * [Fredrik Kant] <fredrik.kant-AT-front.com> Windows setup.
4966 * [Fredrik Kant] <fredrik.kant-AT-front.com> Windows setup.
4974 * [Syver Enstad] <syver-en-AT-online.no> Windows setup.
4967 * [Syver Enstad] <syver-en-AT-online.no> Windows setup.
4975 * [Richard] <rxe-AT-renre-europe.com> Global embedding.
4968 * [Richard] <rxe-AT-renre-europe.com> Global embedding.
4976 * [Hayden Callow] <h.callow-AT-elec.canterbury.ac.nz> Gnuplot.py 1.6
4969 * [Hayden Callow] <h.callow-AT-elec.canterbury.ac.nz> Gnuplot.py 1.6
4977 compatibility.
4970 compatibility.
4978 * [Leonardo Santagada] <retype-AT-terra.com.br> Fixes for Windows
4971 * [Leonardo Santagada] <retype-AT-terra.com.br> Fixes for Windows
4979 installation.
4972 installation.
4980 * [Christopher Armstrong] <radix-AT-twistedmatrix.com> Bugfixes.
4973 * [Christopher Armstrong] <radix-AT-twistedmatrix.com> Bugfixes.
4981 * [Francois Pinard] <pinard-AT-iro.umontreal.ca> Code and
4974 * [Francois Pinard] <pinard-AT-iro.umontreal.ca> Code and
4982 documentation fixes.
4975 documentation fixes.
4983 * [Cory Dodt] <cdodt-AT-fcoe.k12.ca.us> Bug reports and Windows
4976 * [Cory Dodt] <cdodt-AT-fcoe.k12.ca.us> Bug reports and Windows
4984 ideas. Patches for Windows installer.
4977 ideas. Patches for Windows installer.
4985 * [Olivier Aubert] <oaubert-AT-bat710.univ-lyon1.fr> New magics.
4978 * [Olivier Aubert] <oaubert-AT-bat710.univ-lyon1.fr> New magics.
4986 * [King C. Shu] <kingshu-AT-myrealbox.com> Autoindent patch.
4979 * [King C. Shu] <kingshu-AT-myrealbox.com> Autoindent patch.
4987 * [Chris Drexler] <chris-AT-ac-drexler.de> Readline packages for
4980 * [Chris Drexler] <chris-AT-ac-drexler.de> Readline packages for
4988 Win32/CygWin.
4981 Win32/CygWin.
4989 * [Gustavo Cordova Avila] <gcordova-AT-sismex.com> EvalDict code for
4982 * [Gustavo Cordova Avila] <gcordova-AT-sismex.com> EvalDict code for
4990 nice, lightweight string interpolation.
4983 nice, lightweight string interpolation.
4991 * [Kasper Souren] <Kasper.Souren-AT-ircam.fr> Bug reports, ideas.
4984 * [Kasper Souren] <Kasper.Souren-AT-ircam.fr> Bug reports, ideas.
4992 * [Gever Tulley] <gever-AT-helium.com> Code contributions.
4985 * [Gever Tulley] <gever-AT-helium.com> Code contributions.
4993 * [Ralf Schmitt] <ralf-AT-brainbot.com> Bug reports & fixes.
4986 * [Ralf Schmitt] <ralf-AT-brainbot.com> Bug reports & fixes.
4994 * [Oliver Sander] <osander-AT-gmx.de> Bug reports.
4987 * [Oliver Sander] <osander-AT-gmx.de> Bug reports.
4995 * [Rod Holland] <rhh-AT-structurelabs.com> Bug reports and fixes to
4988 * [Rod Holland] <rhh-AT-structurelabs.com> Bug reports and fixes to
4996 logging module.
4989 logging module.
4997 * [Daniel 'Dang' Griffith] <pythondev-dang-AT-lazytwinacres.net>
4990 * [Daniel 'Dang' Griffith] <pythondev-dang-AT-lazytwinacres.net>
4998 Fixes, enhancement suggestions for system shell use.
4991 Fixes, enhancement suggestions for system shell use.
4999 * [Viktor Ransmayr] <viktor.ransmayr-AT-t-online.de> Tests and
4992 * [Viktor Ransmayr] <viktor.ransmayr-AT-t-online.de> Tests and
5000 reports on Windows installation issues. Contributed a true Windows
4993 reports on Windows installation issues. Contributed a true Windows
5001 binary installer.
4994 binary installer.
5002 * [Mike Salib] <msalib-AT-mit.edu> Help fixing a subtle bug related
4995 * [Mike Salib] <msalib-AT-mit.edu> Help fixing a subtle bug related
5003 to traceback printing.
4996 to traceback printing.
5004 * [W.J. van der Laan] <gnufnork-AT-hetdigitalegat.nl> Bash-like
4997 * [W.J. van der Laan] <gnufnork-AT-hetdigitalegat.nl> Bash-like
5005 prompt specials.
4998 prompt specials.
5006 * [Antoon Pardon] <Antoon.Pardon-AT-rece.vub.ac.be> Critical fix for
4999 * [Antoon Pardon] <Antoon.Pardon-AT-rece.vub.ac.be> Critical fix for
5007 the multithreaded IPython.
5000 the multithreaded IPython.
5008 * [John Hunter] <jdhunter-AT-nitace.bsd.uchicago.edu> Matplotlib
5001 * [John Hunter] <jdhunter-AT-nitace.bsd.uchicago.edu> Matplotlib
5009 author, helped with all the development of support for matplotlib
5002 author, helped with all the development of support for matplotlib
5010 in IPyhton, including making necessary changes to matplotlib itself.
5003 in IPyhton, including making necessary changes to matplotlib itself.
5011 * [Matthew Arnison] <maffew-AT-cat.org.au> Bug reports, '%run -d' idea.
5004 * [Matthew Arnison] <maffew-AT-cat.org.au> Bug reports, '%run -d' idea.
5012 * [Prabhu Ramachandran] <prabhu_r-AT-users.sourceforge.net> Help
5005 * [Prabhu Ramachandran] <prabhu_r-AT-users.sourceforge.net> Help
5013 with (X)Emacs support, threading patches, ideas...
5006 with (X)Emacs support, threading patches, ideas...
5014 * [Norbert Tretkowski] <tretkowski-AT-inittab.de> help with Debian
5007 * [Norbert Tretkowski] <tretkowski-AT-inittab.de> help with Debian
5015 packaging and distribution.
5008 packaging and distribution.
5016 * [George Sakkis] <gsakkis-AT-eden.rutgers.edu> New matcher for
5009 * [George Sakkis] <gsakkis-AT-eden.rutgers.edu> New matcher for
5017 tab-completing named arguments of user-defined functions.
5010 tab-completing named arguments of user-defined functions.
5018 * [Jörgen Stenarson] <jorgen.stenarson-AT-bostream.nu> Wildcard
5011 * [Jörgen Stenarson] <jorgen.stenarson-AT-bostream.nu> Wildcard
5019 support implementation for searching namespaces.
5012 support implementation for searching namespaces.
5020 * [Vivian De Smedt] <vivian-AT-vdesmedt.com> Debugger enhancements,
5013 * [Vivian De Smedt] <vivian-AT-vdesmedt.com> Debugger enhancements,
5021 so that when pdb is activated from within IPython, coloring, tab
5014 so that when pdb is activated from within IPython, coloring, tab
5022 completion and other features continue to work seamlessly.
5015 completion and other features continue to work seamlessly.
5023 * [Scott Tsai] <scottt958-AT-yahoo.com.tw> Support for automatic
5016 * [Scott Tsai] <scottt958-AT-yahoo.com.tw> Support for automatic
5024 editor invocation on syntax errors (see
5017 editor invocation on syntax errors (see
5025 http://www.scipy.net/roundup/ipython/issue36).
5018 http://www.scipy.net/roundup/ipython/issue36).
5026 * [Alexander Belchenko] <bialix-AT-ukr.net> Improvements for win32
5019 * [Alexander Belchenko] <bialix-AT-ukr.net> Improvements for win32
5027 paging system.
5020 paging system.
5028 * [Will Maier] <willmaier-AT-ml1.net> Official OpenBSD port.
5021 * [Will Maier] <willmaier-AT-ml1.net> Official OpenBSD port.
5029
5022
General Comments 0
You need to be logged in to leave comments. Login now