Show More
@@ -1,645 +1,558 | |||
|
1 | 1 | # -*- coding: utf-8 -*- |
|
2 | 2 | #***************************************************************************** |
|
3 | 3 | # Copyright (C) 2001-2004 Fernando Perez. <fperez@colorado.edu> |
|
4 | 4 | # |
|
5 | 5 | # Distributed under the terms of the BSD License. The full license is in |
|
6 | 6 | # the file COPYING, distributed as part of this software. |
|
7 | 7 | #***************************************************************************** |
|
8 | 8 | |
|
9 | 9 | __doc__ = """ |
|
10 | 10 | IPython -- An enhanced Interactive Python |
|
11 | 11 | ========================================= |
|
12 | 12 | |
|
13 | 13 | A Python shell with automatic history (input and output), dynamic object |
|
14 | 14 | introspection, easier configuration, command completion, access to the system |
|
15 | 15 | shell and more. |
|
16 | 16 | |
|
17 | 17 | IPython can also be embedded in running programs. See EMBEDDING below. |
|
18 | 18 | |
|
19 | 19 | |
|
20 | 20 | USAGE |
|
21 | 21 | ipython [options] files |
|
22 | 22 | |
|
23 | 23 | If invoked with no options, it executes all the files listed in |
|
24 | 24 | sequence and drops you into the interpreter while still acknowledging |
|
25 | 25 | any options you may have set in your ipythonrc file. This behavior is |
|
26 | 26 | different from standard Python, which when called as python -i will |
|
27 | 27 | only execute one file and will ignore your configuration setup. |
|
28 | 28 | |
|
29 | 29 | Please note that some of the configuration options are not available at |
|
30 | 30 | the command line, simply because they are not practical here. Look into |
|
31 | 31 | your ipythonrc configuration file for details on those. This file |
|
32 | 32 | typically installed in the $HOME/.ipython directory. |
|
33 | 33 | |
|
34 | 34 | For Windows users, $HOME resolves to C:\\Documents and |
|
35 | 35 | Settings\\YourUserName in most instances, and _ipython is used instead |
|
36 | 36 | of .ipython, since some Win32 programs have problems with dotted names |
|
37 | 37 | in directories. |
|
38 | 38 | |
|
39 | 39 | In the rest of this text, we will refer to this directory as |
|
40 | 40 | IPYTHONDIR. |
|
41 | 41 | |
|
42 | ||
|
43 | SPECIAL THREADING OPTIONS | |
|
44 | The following special options are ONLY valid at the beginning of the | |
|
45 | command line, and not later. This is because they control the initial- | |
|
46 | ization of ipython itself, before the normal option-handling mechanism | |
|
47 | is active. | |
|
48 | ||
|
49 | -gthread, -qthread, -q4thread, -wthread, -pylab | |
|
50 | ||
|
51 | Only ONE of these can be given, and it can only be given as the | |
|
52 | first option passed to IPython (it will have no effect in any | |
|
53 | other position). They provide threading support for the GTK, QT | |
|
54 | and WXWidgets toolkits, and for the matplotlib library. | |
|
55 | ||
|
56 | With any of the first four options, IPython starts running a | |
|
57 | separate thread for the graphical toolkit's operation, so that | |
|
58 | you can open and control graphical elements from within an | |
|
59 | IPython command line, without blocking. All four provide | |
|
60 | essentially the same functionality, respectively for GTK, QT3, | |
|
61 | QT4 and WXWidgets (via their Python interfaces). | |
|
62 | ||
|
63 | Note that with -wthread, you can additionally use the -wxversion | |
|
64 | option to request a specific version of wx to be used. This | |
|
65 | requires that you have the 'wxversion' Python module installed, | |
|
66 | which is part of recent wxPython distributions. | |
|
67 | ||
|
68 | If -pylab is given, IPython loads special support for the mat- | |
|
69 | plotlib library (http://matplotlib.sourceforge.net), allowing | |
|
70 | interactive usage of any of its backends as defined in the | |
|
71 | user's .matplotlibrc file. It automatically activates GTK, QT | |
|
72 | or WX threading for IPyhton if the choice of matplotlib backend | |
|
73 | requires it. It also modifies the %run command to correctly | |
|
74 | execute (without blocking) any matplotlib-based script which | |
|
75 | calls show() at the end. | |
|
76 | ||
|
77 | -tk The -g/q/q4/wthread options, and -pylab (if matplotlib is | |
|
78 | configured to use GTK, QT or WX), will normally block Tk | |
|
79 | graphical interfaces. This means that when GTK, QT or WX | |
|
80 | threading is active, any attempt to open a Tk GUI will result in | |
|
81 | a dead window, and possibly cause the Python interpreter to | |
|
82 | crash. An extra option, -tk, is available to address this | |
|
83 | issue. It can ONLY be given as a SECOND option after any of the | |
|
84 | above (-gthread, -qthread, q4thread, -wthread or -pylab). | |
|
85 | ||
|
86 | If -tk is given, IPython will try to coordinate Tk threading | |
|
87 | with GTK, QT or WX. This is however potentially unreliable, and | |
|
88 | you will have to test on your platform and Python configuration | |
|
89 | to determine whether it works for you. Debian users have | |
|
90 | reported success, apparently due to the fact that Debian builds | |
|
91 | all of Tcl, Tk, Tkinter and Python with pthreads support. Under | |
|
92 | other Linux environments (such as Fedora Core 2/3), this option | |
|
93 | has caused random crashes and lockups of the Python interpreter. | |
|
94 | Under other operating systems (Mac OSX and Windows), you'll need | |
|
95 | to try it to find out, since currently no user reports are | |
|
96 | available. | |
|
97 | ||
|
98 | There is unfortunately no way for IPython to determine at run- | |
|
99 | time whether -tk will work reliably or not, so you will need to | |
|
100 | do some experiments before relying on it for regular work. | |
|
101 | ||
|
102 | A WARNING ABOUT SIGNALS AND THREADS | |
|
103 | ||
|
104 | When any of the thread systems (GTK, QT or WX) are active, either | |
|
105 | directly or via -pylab with a threaded backend, it is impossible to | |
|
106 | interrupt long-running Python code via Ctrl-C. IPython can not pass | |
|
107 | the KeyboardInterrupt exception (or the underlying SIGINT) across | |
|
108 | threads, so any long-running process started from IPython will run to | |
|
109 | completion, or will have to be killed via an external (OS-based) | |
|
110 | mechanism. | |
|
111 | ||
|
112 | To the best of my knowledge, this limitation is imposed by the Python | |
|
113 | interpreter itself, and it comes from the difficulty of writing | |
|
114 | portable signal/threaded code. If any user is an expert on this topic | |
|
115 | and can suggest a better solution, I would love to hear about it. In | |
|
116 | the IPython sources, look at the shell.py module, and in particular at | |
|
117 | the runcode() method. | |
|
118 | ||
|
119 | 42 | REGULAR OPTIONS |
|
120 | 43 | After the above threading options have been given, regular options can |
|
121 | 44 | follow in any order. All options can be abbreviated to their shortest |
|
122 | 45 | non-ambiguous form and are case-sensitive. One or two dashes can be |
|
123 | 46 | used. Some options have an alternate short form, indicated after a |. |
|
124 | 47 | |
|
125 | 48 | Most options can also be set from your ipythonrc configuration file. |
|
126 | 49 | See the provided examples for assistance. Options given on the comman- |
|
127 | 50 | dline override the values set in the ipythonrc file. |
|
128 | 51 | |
|
129 | 52 | All options with a [no] prepended can be specified in negated form |
|
130 | 53 | (using -nooption instead of -option) to turn the feature off. |
|
131 | 54 | |
|
132 | 55 | -h, --help |
|
133 | 56 | Show summary of options. |
|
134 | 57 | |
|
135 | -pylab This can only be given as the first option passed to IPython (it | |
|
136 | will have no effect in any other position). It adds special sup- | |
|
137 | port for the matplotlib library (http://matplotlib.source- | |
|
138 | forge.net), allowing interactive usage of any of its backends as | |
|
139 | defined in the user's .matplotlibrc file. It automatically | |
|
140 | activates GTK or WX threading for IPyhton if the choice of mat- | |
|
141 | plotlib backend requires it. It also modifies the @run command | |
|
142 | to correctly execute (without blocking) any matplotlib-based | |
|
143 | script which calls show() at the end. | |
|
144 | ||
|
145 | 58 | -autocall <val> |
|
146 | 59 | Make IPython automatically call any callable object even if you |
|
147 | 60 | didn't type explicit parentheses. For example, 'str 43' becomes |
|
148 | 61 | 'str(43)' automatically. The value can be '0' to disable the |
|
149 | 62 | feature, '1' for 'smart' autocall, where it is not applied if |
|
150 | 63 | there are no more arguments on the line, and '2' for 'full' |
|
151 | 64 | autocall, where all callable objects are automatically called |
|
152 | 65 | (even if no arguments are present). The default is '1'. |
|
153 | 66 | |
|
154 | 67 | -[no]autoindent |
|
155 | 68 | Turn automatic indentation on/off. |
|
156 | 69 | |
|
157 | 70 | -[no]automagic |
|
158 | 71 | Make magic commands automatic (without needing their first char- |
|
159 | 72 | acter to be %). Type %magic at the IPython prompt for more |
|
160 | 73 | information. |
|
161 | 74 | |
|
162 | 75 | -[no]autoedit_syntax |
|
163 | 76 | When a syntax error occurs after editing a file, automatically |
|
164 | 77 | open the file to the trouble causing line for convenient fixing. |
|
165 | 78 | |
|
166 | 79 | -[no]banner |
|
167 | 80 | Print the intial information banner (default on). |
|
168 | 81 | |
|
169 | 82 | -c <command> |
|
170 | 83 | Execute the given command string, and set sys.argv to ['c']. |
|
171 | 84 | This is similar to the -c option in the normal Python inter- |
|
172 | 85 | preter. |
|
173 | 86 | |
|
174 | 87 | -cache_size|cs <n> |
|
175 | 88 | Size of the output cache (maximum number of entries to hold in |
|
176 | 89 | memory). The default is 1000, you can change it permanently in |
|
177 | 90 | your config file. Setting it to 0 completely disables the |
|
178 | 91 | caching system, and the minimum value accepted is 20 (if you |
|
179 | 92 | provide a value less than 20, it is reset to 0 and a warning is |
|
180 | 93 | issued). This limit is defined because otherwise you'll spend |
|
181 | 94 | more time re-flushing a too small cache than working. |
|
182 | 95 | |
|
183 | 96 | -classic|cl |
|
184 | 97 | Gives IPython a similar feel to the classic Python prompt. |
|
185 | 98 | |
|
186 | 99 | -colors <scheme> |
|
187 | 100 | Color scheme for prompts and exception reporting. Currently |
|
188 | 101 | implemented: NoColor, Linux, and LightBG. |
|
189 | 102 | |
|
190 | 103 | -[no]color_info |
|
191 | 104 | IPython can display information about objects via a set of func- |
|
192 | 105 | tions, and optionally can use colors for this, syntax highlight- |
|
193 | 106 | ing source code and various other elements. However, because |
|
194 | 107 | this information is passed through a pager (like 'less') and |
|
195 | 108 | many pagers get confused with color codes, this option is off by |
|
196 | 109 | default. You can test it and turn it on permanently in your |
|
197 | 110 | ipythonrc file if it works for you. As a reference, the 'less' |
|
198 | 111 | pager supplied with Mandrake 8.2 works ok, but that in RedHat |
|
199 | 112 | 7.2 doesn't. |
|
200 | 113 | |
|
201 | 114 | Test it and turn it on permanently if it works with your system. |
|
202 | 115 | The magic function @color_info allows you to toggle this inter- |
|
203 | 116 | actively for testing. |
|
204 | 117 | |
|
205 | 118 | -[no]confirm_exit |
|
206 | 119 | Set to confirm when you try to exit IPython with an EOF (Con- |
|
207 | 120 | trol-D in Unix, Control-Z/Enter in Windows). Note that using the |
|
208 | 121 | magic functions @Exit or @Quit you can force a direct exit, |
|
209 | 122 | bypassing any confirmation. |
|
210 | 123 | |
|
211 | 124 | -[no]debug |
|
212 | 125 | Show information about the loading process. Very useful to pin |
|
213 | 126 | down problems with your configuration files or to get details |
|
214 | 127 | about session restores. |
|
215 | 128 | |
|
216 | 129 | -[no]deep_reload |
|
217 | 130 | IPython can use the deep_reload module which reloads changes in |
|
218 | 131 | modules recursively (it replaces the reload() function, so you |
|
219 | 132 | don't need to change anything to use it). deep_reload() forces a |
|
220 | 133 | full reload of modules whose code may have changed, which the |
|
221 | 134 | default reload() function does not. |
|
222 | 135 | |
|
223 | 136 | When deep_reload is off, IPython will use the normal reload(), |
|
224 | 137 | but deep_reload will still be available as dreload(). This fea- |
|
225 | 138 | ture is off by default [which means that you have both normal |
|
226 | 139 | reload() and dreload()]. |
|
227 | 140 | |
|
228 | 141 | -editor <name> |
|
229 | 142 | Which editor to use with the @edit command. By default, IPython |
|
230 | 143 | will honor your EDITOR environment variable (if not set, vi is |
|
231 | 144 | the Unix default and notepad the Windows one). Since this editor |
|
232 | 145 | is invoked on the fly by IPython and is meant for editing small |
|
233 | 146 | code snippets, you may want to use a small, lightweight editor |
|
234 | 147 | here (in case your default EDITOR is something like Emacs). |
|
235 | 148 | |
|
236 | 149 | -ipythondir <name> |
|
237 | 150 | The name of your IPython configuration directory IPYTHONDIR. |
|
238 | 151 | This can also be specified through the environment variable |
|
239 | 152 | IPYTHONDIR. |
|
240 | 153 | |
|
241 | 154 | -log|l Generate a log file of all input. The file is named |
|
242 | 155 | ipython_log.py in your current directory (which prevents logs |
|
243 | 156 | from multiple IPython sessions from trampling each other). You |
|
244 | 157 | can use this to later restore a session by loading your logfile |
|
245 | 158 | as a file to be executed with option -logplay (see below). |
|
246 | 159 | |
|
247 | 160 | -logfile|lf |
|
248 | 161 | Specify the name of your logfile. |
|
249 | 162 | |
|
250 | 163 | -logplay|lp |
|
251 | 164 | Replay a previous log. For restoring a session as close as pos- |
|
252 | 165 | sible to the state you left it in, use this option (don't just |
|
253 | 166 | run the logfile). With -logplay, IPython will try to reconstruct |
|
254 | 167 | the previous working environment in full, not just execute the |
|
255 | 168 | commands in the logfile. |
|
256 | 169 | When a session is restored, logging is automatically turned on |
|
257 | 170 | again with the name of the logfile it was invoked with (it is |
|
258 | 171 | read from the log header). So once you've turned logging on for |
|
259 | 172 | a session, you can quit IPython and reload it as many times as |
|
260 | 173 | you want and it will continue to log its history and restore |
|
261 | 174 | from the beginning every time. |
|
262 | 175 | |
|
263 | 176 | Caveats: there are limitations in this option. The history vari- |
|
264 | 177 | ables _i*,_* and _dh don't get restored properly. In the future |
|
265 | 178 | we will try to implement full session saving by writing and |
|
266 | 179 | retrieving a failed because of inherent limitations of Python's |
|
267 | 180 | Pickle module, so this may have to wait. |
|
268 | 181 | |
|
269 | 182 | -[no]messages |
|
270 | 183 | Print messages which IPython collects about its startup process |
|
271 | 184 | (default on). |
|
272 | 185 | |
|
273 | 186 | -[no]pdb |
|
274 | 187 | Automatically call the pdb debugger after every uncaught excep- |
|
275 | 188 | tion. If you are used to debugging using pdb, this puts you |
|
276 | 189 | automatically inside of it after any call (either in IPython or |
|
277 | 190 | in code called by it) which triggers an exception which goes |
|
278 | 191 | uncaught. |
|
279 | 192 | |
|
280 | 193 | -[no]pprint |
|
281 | 194 | IPython can optionally use the pprint (pretty printer) module |
|
282 | 195 | for displaying results. pprint tends to give a nicer display of |
|
283 | 196 | nested data structures. If you like it, you can turn it on per- |
|
284 | 197 | manently in your config file (default off). |
|
285 | 198 | |
|
286 | 199 | -profile|p <name> |
|
287 | 200 | Assume that your config file is ipythonrc-<name> (looks in cur- |
|
288 | 201 | rent dir first, then in IPYTHONDIR). This is a quick way to keep |
|
289 | 202 | and load multiple config files for different tasks, especially |
|
290 | 203 | if you use the include option of config files. You can keep a |
|
291 | 204 | basic IPYTHONDIR/ipythonrc file and then have other 'profiles' |
|
292 | 205 | which include this one and load extra things for particular |
|
293 | 206 | tasks. For example: |
|
294 | 207 | |
|
295 | 208 | 1) $HOME/.ipython/ipythonrc : load basic things you always want. |
|
296 | 209 | 2) $HOME/.ipython/ipythonrc-math : load (1) and basic math- |
|
297 | 210 | related modules. |
|
298 | 211 | 3) $HOME/.ipython/ipythonrc-numeric : load (1) and Numeric and |
|
299 | 212 | plotting modules. |
|
300 | 213 | |
|
301 | 214 | Since it is possible to create an endless loop by having circu- |
|
302 | 215 | lar file inclusions, IPython will stop if it reaches 15 recur- |
|
303 | 216 | sive inclusions. |
|
304 | 217 | |
|
305 | 218 | -prompt_in1|pi1 <string> |
|
306 | 219 | Specify the string used for input prompts. Note that if you are |
|
307 | 220 | using numbered prompts, the number is represented with a '\#' in |
|
308 | 221 | the string. Don't forget to quote strings with spaces embedded |
|
309 | 222 | in them. Default: 'In [\#]: '. |
|
310 | 223 | |
|
311 | 224 | Most bash-like escapes can be used to customize IPython's |
|
312 | 225 | prompts, as well as a few additional ones which are IPython-spe- |
|
313 | 226 | cific. All valid prompt escapes are described in detail in the |
|
314 | 227 | Customization section of the IPython HTML/PDF manual. |
|
315 | 228 | |
|
316 | 229 | -prompt_in2|pi2 <string> |
|
317 | 230 | Similar to the previous option, but used for the continuation |
|
318 | 231 | prompts. The special sequence '\D' is similar to '\#', but with |
|
319 | 232 | all digits replaced dots (so you can have your continuation |
|
320 | 233 | prompt aligned with your input prompt). Default: ' .\D.: ' |
|
321 | 234 | (note three spaces at the start for alignment with 'In [\#]'). |
|
322 | 235 | |
|
323 | 236 | -prompt_out|po <string> |
|
324 | 237 | String used for output prompts, also uses numbers like |
|
325 | 238 | prompt_in1. Default: 'Out[\#]:'. |
|
326 | 239 | |
|
327 | 240 | -quick Start in bare bones mode (no config file loaded). |
|
328 | 241 | |
|
329 | 242 | -rcfile <name> |
|
330 | 243 | Name of your IPython resource configuration file. normally |
|
331 | 244 | IPython loads ipythonrc (from current directory) or |
|
332 | 245 | IPYTHONDIR/ipythonrc. If the loading of your config file fails, |
|
333 | 246 | IPython starts with a bare bones configuration (no modules |
|
334 | 247 | loaded at all). |
|
335 | 248 | |
|
336 | 249 | -[no]readline |
|
337 | 250 | Use the readline library, which is needed to support name com- |
|
338 | 251 | pletion and command history, among other things. It is enabled |
|
339 | 252 | by default, but may cause problems for users of X/Emacs in |
|
340 | 253 | Python comint or shell buffers. |
|
341 | 254 | |
|
342 | 255 | Note that emacs 'eterm' buffers (opened with M-x term) support |
|
343 | 256 | IPython's readline and syntax coloring fine, only 'emacs' (M-x |
|
344 | 257 | shell and C-c !) buffers do not. |
|
345 | 258 | |
|
346 | 259 | -screen_length|sl <n> |
|
347 | 260 | Number of lines of your screen. This is used to control print- |
|
348 | 261 | ing of very long strings. Strings longer than this number of |
|
349 | 262 | lines will be sent through a pager instead of directly printed. |
|
350 | 263 | |
|
351 | 264 | The default value for this is 0, which means IPython will auto- |
|
352 | 265 | detect your screen size every time it needs to print certain |
|
353 | 266 | potentially long strings (this doesn't change the behavior of |
|
354 | 267 | the 'print' keyword, it's only triggered internally). If for |
|
355 | 268 | some reason this isn't working well (it needs curses support), |
|
356 | 269 | specify it yourself. Otherwise don't change the default. |
|
357 | 270 | |
|
358 | 271 | -separate_in|si <string> |
|
359 | 272 | Separator before input prompts. Default '0. |
|
360 | 273 | |
|
361 | 274 | -separate_out|so <string> |
|
362 | 275 | Separator before output prompts. Default: 0 (nothing). |
|
363 | 276 | |
|
364 | 277 | -separate_out2|so2 <string> |
|
365 | 278 | Separator after output prompts. Default: 0 (nothing). |
|
366 | 279 | |
|
367 | 280 | -nosep Shorthand for '-separate_in 0 -separate_out 0 -separate_out2 0'. |
|
368 | 281 | Simply removes all input/output separators. |
|
369 | 282 | |
|
370 | 283 | -upgrade |
|
371 | 284 | Allows you to upgrade your IPYTHONDIR configuration when you |
|
372 | 285 | install a new version of IPython. Since new versions may |
|
373 | 286 | include new command lines options or example files, this copies |
|
374 | 287 | updated ipythonrc-type files. However, it backs up (with a .old |
|
375 | 288 | extension) all files which it overwrites so that you can merge |
|
376 | 289 | back any custimizations you might have in your personal files. |
|
377 | 290 | |
|
378 | 291 | -Version |
|
379 | 292 | Print version information and exit. |
|
380 | 293 | |
|
381 | 294 | -wxversion <string> |
|
382 | 295 | Select a specific version of wxPython (used in conjunction with |
|
383 | 296 | -wthread). Requires the wxversion module, part of recent |
|
384 | 297 | wxPython distributions. |
|
385 | 298 | |
|
386 | 299 | -xmode <modename> |
|
387 | 300 | Mode for exception reporting. The valid modes are Plain, Con- |
|
388 | 301 | text, and Verbose. |
|
389 | 302 | |
|
390 | 303 | - Plain: similar to python's normal traceback printing. |
|
391 | 304 | |
|
392 | 305 | - Context: prints 5 lines of context source code around each |
|
393 | 306 | line in the traceback. |
|
394 | 307 | |
|
395 | 308 | - Verbose: similar to Context, but additionally prints the vari- |
|
396 | 309 | ables currently visible where the exception happened (shortening |
|
397 | 310 | their strings if too long). This can potentially be very slow, |
|
398 | 311 | if you happen to have a huge data structure whose string repre- |
|
399 | 312 | sentation is complex to compute. Your computer may appear to |
|
400 | 313 | freeze for a while with cpu usage at 100%. If this occurs, you |
|
401 | 314 | can cancel the traceback with Ctrl-C (maybe hitting it more than |
|
402 | 315 | once). |
|
403 | 316 | |
|
404 | 317 | |
|
405 | 318 | EMBEDDING |
|
406 | 319 | It is possible to start an IPython instance inside your own Python pro- |
|
407 | 320 | grams. In the documentation example files there are some illustrations |
|
408 | 321 | on how to do this. |
|
409 | 322 | |
|
410 | 323 | This feature allows you to evalutate dynamically the state of your |
|
411 | 324 | code, operate with your variables, analyze them, etc. Note however |
|
412 | 325 | that any changes you make to values while in the shell do NOT propagate |
|
413 | 326 | back to the running code, so it is safe to modify your values because |
|
414 | 327 | you won't break your code in bizarre ways by doing so. |
|
415 | 328 | """ |
|
416 | 329 | |
|
417 | 330 | cmd_line_usage = __doc__ |
|
418 | 331 | |
|
419 | 332 | #--------------------------------------------------------------------------- |
|
420 | 333 | interactive_usage = """ |
|
421 | 334 | IPython -- An enhanced Interactive Python |
|
422 | 335 | ========================================= |
|
423 | 336 | |
|
424 | 337 | IPython offers a combination of convenient shell features, special commands |
|
425 | 338 | and a history mechanism for both input (command history) and output (results |
|
426 | 339 | caching, similar to Mathematica). It is intended to be a fully compatible |
|
427 | 340 | replacement for the standard Python interpreter, while offering vastly |
|
428 | 341 | improved functionality and flexibility. |
|
429 | 342 | |
|
430 | 343 | At your system command line, type 'ipython -help' to see the command line |
|
431 | 344 | options available. This document only describes interactive features. |
|
432 | 345 | |
|
433 | 346 | Warning: IPython relies on the existence of a global variable called __IP which |
|
434 | 347 | controls the shell itself. If you redefine __IP to anything, bizarre behavior |
|
435 | 348 | will quickly occur. |
|
436 | 349 | |
|
437 | 350 | MAIN FEATURES |
|
438 | 351 | |
|
439 | 352 | * Access to the standard Python help. As of Python 2.1, a help system is |
|
440 | 353 | available with access to object docstrings and the Python manuals. Simply |
|
441 | 354 | type 'help' (no quotes) to access it. |
|
442 | 355 | |
|
443 | 356 | * Magic commands: type %magic for information on the magic subsystem. |
|
444 | 357 | |
|
445 | 358 | * System command aliases, via the %alias command or the ipythonrc config file. |
|
446 | 359 | |
|
447 | 360 | * Dynamic object information: |
|
448 | 361 | |
|
449 | 362 | Typing ?word or word? prints detailed information about an object. If |
|
450 | 363 | certain strings in the object are too long (docstrings, code, etc.) they get |
|
451 | 364 | snipped in the center for brevity. |
|
452 | 365 | |
|
453 | 366 | Typing ??word or word?? gives access to the full information without |
|
454 | 367 | snipping long strings. Long strings are sent to the screen through the less |
|
455 | 368 | pager if longer than the screen, printed otherwise. |
|
456 | 369 | |
|
457 | 370 | The ?/?? system gives access to the full source code for any object (if |
|
458 | 371 | available), shows function prototypes and other useful information. |
|
459 | 372 | |
|
460 | 373 | If you just want to see an object's docstring, type '%pdoc object' (without |
|
461 | 374 | quotes, and without % if you have automagic on). |
|
462 | 375 | |
|
463 | 376 | Both %pdoc and ?/?? give you access to documentation even on things which are |
|
464 | 377 | not explicitely defined. Try for example typing {}.get? or after import os, |
|
465 | 378 | type os.path.abspath??. The magic functions %pdef, %source and %file operate |
|
466 | 379 | similarly. |
|
467 | 380 | |
|
468 | 381 | * Completion in the local namespace, by typing TAB at the prompt. |
|
469 | 382 | |
|
470 | 383 | At any time, hitting tab will complete any available python commands or |
|
471 | 384 | variable names, and show you a list of the possible completions if there's |
|
472 | 385 | no unambiguous one. It will also complete filenames in the current directory. |
|
473 | 386 | |
|
474 | 387 | This feature requires the readline and rlcomplete modules, so it won't work |
|
475 | 388 | if your Python lacks readline support (such as under Windows). |
|
476 | 389 | |
|
477 | 390 | * Search previous command history in two ways (also requires readline): |
|
478 | 391 | |
|
479 | 392 | - Start typing, and then use Ctrl-p (previous,up) and Ctrl-n (next,down) to |
|
480 | 393 | search through only the history items that match what you've typed so |
|
481 | 394 | far. If you use Ctrl-p/Ctrl-n at a blank prompt, they just behave like |
|
482 | 395 | normal arrow keys. |
|
483 | 396 | |
|
484 | 397 | - Hit Ctrl-r: opens a search prompt. Begin typing and the system searches |
|
485 | 398 | your history for lines that match what you've typed so far, completing as |
|
486 | 399 | much as it can. |
|
487 | 400 | |
|
488 | 401 | * Persistent command history across sessions (readline required). |
|
489 | 402 | |
|
490 | 403 | * Logging of input with the ability to save and restore a working session. |
|
491 | 404 | |
|
492 | 405 | * System escape with !. Typing !ls will run 'ls' in the current directory. |
|
493 | 406 | |
|
494 | 407 | * The reload command does a 'deep' reload of a module: changes made to the |
|
495 | 408 | module since you imported will actually be available without having to exit. |
|
496 | 409 | |
|
497 | 410 | * Verbose and colored exception traceback printouts. See the magic xmode and |
|
498 | 411 | xcolor functions for details (just type %magic). |
|
499 | 412 | |
|
500 | 413 | * Input caching system: |
|
501 | 414 | |
|
502 | 415 | IPython offers numbered prompts (In/Out) with input and output caching. All |
|
503 | 416 | input is saved and can be retrieved as variables (besides the usual arrow |
|
504 | 417 | key recall). |
|
505 | 418 | |
|
506 | 419 | The following GLOBAL variables always exist (so don't overwrite them!): |
|
507 | 420 | _i: stores previous input. |
|
508 | 421 | _ii: next previous. |
|
509 | 422 | _iii: next-next previous. |
|
510 | 423 | _ih : a list of all input _ih[n] is the input from line n. |
|
511 | 424 | |
|
512 | 425 | Additionally, global variables named _i<n> are dynamically created (<n> |
|
513 | 426 | being the prompt counter), such that _i<n> == _ih[<n>] |
|
514 | 427 | |
|
515 | 428 | For example, what you typed at prompt 14 is available as _i14 and _ih[14]. |
|
516 | 429 | |
|
517 | 430 | You can create macros which contain multiple input lines from this history, |
|
518 | 431 | for later re-execution, with the %macro function. |
|
519 | 432 | |
|
520 | 433 | The history function %hist allows you to see any part of your input history |
|
521 | 434 | by printing a range of the _i variables. Note that inputs which contain |
|
522 | 435 | magic functions (%) appear in the history with a prepended comment. This is |
|
523 | 436 | because they aren't really valid Python code, so you can't exec them. |
|
524 | 437 | |
|
525 | 438 | * Output caching system: |
|
526 | 439 | |
|
527 | 440 | For output that is returned from actions, a system similar to the input |
|
528 | 441 | cache exists but using _ instead of _i. Only actions that produce a result |
|
529 | 442 | (NOT assignments, for example) are cached. If you are familiar with |
|
530 | 443 | Mathematica, IPython's _ variables behave exactly like Mathematica's % |
|
531 | 444 | variables. |
|
532 | 445 | |
|
533 | 446 | The following GLOBAL variables always exist (so don't overwrite them!): |
|
534 | 447 | _ (one underscore): previous output. |
|
535 | 448 | __ (two underscores): next previous. |
|
536 | 449 | ___ (three underscores): next-next previous. |
|
537 | 450 | |
|
538 | 451 | Global variables named _<n> are dynamically created (<n> being the prompt |
|
539 | 452 | counter), such that the result of output <n> is always available as _<n>. |
|
540 | 453 | |
|
541 | 454 | Finally, a global dictionary named _oh exists with entries for all lines |
|
542 | 455 | which generated output. |
|
543 | 456 | |
|
544 | 457 | * Directory history: |
|
545 | 458 | |
|
546 | 459 | Your history of visited directories is kept in the global list _dh, and the |
|
547 | 460 | magic %cd command can be used to go to any entry in that list. |
|
548 | 461 | |
|
549 | 462 | * Auto-parentheses and auto-quotes (adapted from Nathan Gray's LazyPython) |
|
550 | 463 | |
|
551 | 464 | 1. Auto-parentheses |
|
552 | 465 | Callable objects (i.e. functions, methods, etc) can be invoked like |
|
553 | 466 | this (notice the commas between the arguments): |
|
554 | 467 | >>> callable_ob arg1, arg2, arg3 |
|
555 | 468 | and the input will be translated to this: |
|
556 | 469 | --> callable_ob(arg1, arg2, arg3) |
|
557 | 470 | You can force auto-parentheses by using '/' as the first character |
|
558 | 471 | of a line. For example: |
|
559 | 472 | >>> /globals # becomes 'globals()' |
|
560 | 473 | Note that the '/' MUST be the first character on the line! This |
|
561 | 474 | won't work: |
|
562 | 475 | >>> print /globals # syntax error |
|
563 | 476 | |
|
564 | 477 | In most cases the automatic algorithm should work, so you should |
|
565 | 478 | rarely need to explicitly invoke /. One notable exception is if you |
|
566 | 479 | are trying to call a function with a list of tuples as arguments (the |
|
567 | 480 | parenthesis will confuse IPython): |
|
568 | 481 | In [1]: zip (1,2,3),(4,5,6) # won't work |
|
569 | 482 | but this will work: |
|
570 | 483 | In [2]: /zip (1,2,3),(4,5,6) |
|
571 | 484 | ------> zip ((1,2,3),(4,5,6)) |
|
572 | 485 | Out[2]= [(1, 4), (2, 5), (3, 6)] |
|
573 | 486 | |
|
574 | 487 | IPython tells you that it has altered your command line by |
|
575 | 488 | displaying the new command line preceded by -->. e.g.: |
|
576 | 489 | In [18]: callable list |
|
577 | 490 | -------> callable (list) |
|
578 | 491 | |
|
579 | 492 | 2. Auto-Quoting |
|
580 | 493 | You can force auto-quoting of a function's arguments by using ',' as |
|
581 | 494 | the first character of a line. For example: |
|
582 | 495 | >>> ,my_function /home/me # becomes my_function("/home/me") |
|
583 | 496 | |
|
584 | 497 | If you use ';' instead, the whole argument is quoted as a single |
|
585 | 498 | string (while ',' splits on whitespace): |
|
586 | 499 | >>> ,my_function a b c # becomes my_function("a","b","c") |
|
587 | 500 | >>> ;my_function a b c # becomes my_function("a b c") |
|
588 | 501 | |
|
589 | 502 | Note that the ',' MUST be the first character on the line! This |
|
590 | 503 | won't work: |
|
591 | 504 | >>> x = ,my_function /home/me # syntax error |
|
592 | 505 | """ |
|
593 | 506 | |
|
594 | 507 | quick_reference = r""" |
|
595 | 508 | IPython -- An enhanced Interactive Python - Quick Reference Card |
|
596 | 509 | ================================================================ |
|
597 | 510 | |
|
598 | 511 | obj?, obj?? : Get help, or more help for object (also works as |
|
599 | 512 | ?obj, ??obj). |
|
600 | 513 | ?foo.*abc* : List names in 'foo' containing 'abc' in them. |
|
601 | 514 | %magic : Information about IPython's 'magic' % functions. |
|
602 | 515 | |
|
603 | 516 | Magic functions are prefixed by %, and typically take their arguments without |
|
604 | 517 | parentheses, quotes or even commas for convenience. |
|
605 | 518 | |
|
606 | 519 | Example magic function calls: |
|
607 | 520 | |
|
608 | 521 | %alias d ls -F : 'd' is now an alias for 'ls -F' |
|
609 | 522 | alias d ls -F : Works if 'alias' not a python name |
|
610 | 523 | alist = %alias : Get list of aliases to 'alist' |
|
611 | 524 | cd /usr/share : Obvious. cd -<tab> to choose from visited dirs. |
|
612 | 525 | %cd?? : See help AND source for magic %cd |
|
613 | 526 | |
|
614 | 527 | System commands: |
|
615 | 528 | |
|
616 | 529 | !cp a.txt b/ : System command escape, calls os.system() |
|
617 | 530 | cp a.txt b/ : after %rehashx, most system commands work without ! |
|
618 | 531 | cp ${f}.txt $bar : Variable expansion in magics and system commands |
|
619 | 532 | files = !ls /usr : Capture sytem command output |
|
620 | 533 | files.s, files.l, files.n: "a b c", ['a','b','c'], 'a\nb\nc' |
|
621 | 534 | |
|
622 | 535 | History: |
|
623 | 536 | |
|
624 | 537 | _i, _ii, _iii : Previous, next previous, next next previous input |
|
625 | 538 | _i4, _ih[2:5] : Input history line 4, lines 2-4 |
|
626 | 539 | exec _i81 : Execute input history line #81 again |
|
627 | 540 | %rep 81 : Edit input history line #81 |
|
628 | 541 | _, __, ___ : previous, next previous, next next previous output |
|
629 | 542 | _dh : Directory history |
|
630 | 543 | _oh : Output history |
|
631 | 544 | %hist : Command history. '%hist -g foo' search history for 'foo' |
|
632 | 545 | |
|
633 | 546 | Autocall: |
|
634 | 547 | |
|
635 | 548 | f 1,2 : f(1,2) |
|
636 | 549 | /f 1,2 : f(1,2) (forced autoparen) |
|
637 | 550 | ,f 1 2 : f("1","2") |
|
638 | 551 | ;f 1 2 : f("1 2") |
|
639 | 552 | |
|
640 | 553 | Remember: TAB completion works in many contexts, not just file names |
|
641 | 554 | or python names. |
|
642 | 555 | |
|
643 | 556 | The following magic functions are currently available: |
|
644 | 557 | |
|
645 | 558 | """ |
@@ -1,395 +1,339 | |||
|
1 | 1 | .\" Hey, EMACS: -*- nroff -*- |
|
2 | 2 | .\" First parameter, NAME, should be all caps |
|
3 | 3 | .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection |
|
4 | 4 | .\" other parameters are allowed: see man(7), man(1) |
|
5 | 5 | .TH IPYTHON 1 "November 30, 2004" |
|
6 | 6 | .\" Please adjust this date whenever revising the manpage. |
|
7 | 7 | .\" |
|
8 | 8 | .\" Some roff macros, for reference: |
|
9 | 9 | .\" .nh disable hyphenation |
|
10 | 10 | .\" .hy enable hyphenation |
|
11 | 11 | .\" .ad l left justify |
|
12 | 12 | .\" .ad b justify to both left and right margins |
|
13 | 13 | .\" .nf disable filling |
|
14 | 14 | .\" .fi enable filling |
|
15 | 15 | .\" .br insert line break |
|
16 | 16 | .\" .sp <n> insert n+1 empty lines |
|
17 | 17 | .\" for manpage-specific macros, see man(7) and groff_man(7) |
|
18 | 18 | .\" .SH section heading |
|
19 | 19 | .\" .SS secondary section heading |
|
20 | 20 | .\" |
|
21 | 21 | .\" |
|
22 | 22 | .\" To preview this page as plain text: nroff -man ipython.1 |
|
23 | 23 | .\" |
|
24 | 24 | .SH NAME |
|
25 | 25 | ipython \- An Enhanced Interactive Python |
|
26 | 26 | .SH SYNOPSIS |
|
27 | 27 | .B ipython |
|
28 | 28 | .RI [ options ] " files" ... |
|
29 | 29 | .SH DESCRIPTION |
|
30 | 30 | An interactive Python shell with automatic history (input and output), |
|
31 | 31 | dynamic object introspection, easier configuration, command |
|
32 | 32 | completion, access to the system shell, integration with numerical and |
|
33 | 33 | scientific computing tools, and more. |
|
34 | .SH SPECIAL THREADING OPTIONS | |
|
35 | The following special options are ONLY valid at the beginning of the command | |
|
36 | line, and not later. This is because they control the initialization of | |
|
37 | ipython itself, before the normal option-handling mechanism is active. | |
|
38 | .TP | |
|
39 | .B \-gthread, \-qthread, \-q4thread, \-wthread, \-pylab | |
|
40 | Only ONE of these can be given, and it can only be given as the first option | |
|
41 | passed to IPython (it will have no effect in any other position). They provide | |
|
42 | threading support for the GTK, QT3, QT4 and WXWidgets toolkits, for the | |
|
43 | matplotlib library and Twisted reactor. | |
|
44 | .br | |
|
45 | .sp 1 | |
|
46 | With any of the first four options, IPython starts running a separate thread | |
|
47 | for the graphical toolkit's operation, so that you can open and control | |
|
48 | graphical elements from within an IPython command line, without blocking. All | |
|
49 | four provide essentially the same functionality, respectively for GTK, QT3, QT4 | |
|
50 | and WXWidgets (via their Python interfaces). | |
|
51 | .br | |
|
52 | .sp 1 | |
|
53 | Note that with \-wthread, you can additionally use the \-wxversion option to | |
|
54 | request a specific version of wx to be used. This requires that you have the | |
|
55 | wxversion Python module installed, which is part of recent wxPython | |
|
56 | distributions. | |
|
57 | .br | |
|
58 | .sp 1 | |
|
59 | If \-pylab is given, IPython loads special support for the matplotlib library | |
|
60 | (http://matplotlib.sourceforge.net), allowing interactive usage of any of its | |
|
61 | backends as defined in the user's .matplotlibrc file. It automatically | |
|
62 | activates GTK, QT or WX threading for IPyhton if the choice of matplotlib | |
|
63 | backend requires it. It also modifies the %run command to correctly execute | |
|
64 | (without blocking) any matplotlib-based script which calls show() at the end. | |
|
65 | .TP | |
|
66 | .B \-tk | |
|
67 | The \-g/q/q4/wthread options, and \-pylab (if matplotlib is configured to use | |
|
68 | GTK, QT or WX), will normally block Tk graphical interfaces. This means that | |
|
69 | when GTK, QT or WX threading is active, any attempt to open a Tk GUI will | |
|
70 | result in a dead window, and possibly cause the Python interpreter to crash. | |
|
71 | An extra option, \-tk, is available to address this issue. It can ONLY be | |
|
72 | given as a SECOND option after any of the above (\-gthread, \-qthread, | |
|
73 | \-wthread or \-pylab). | |
|
74 | .br | |
|
75 | .sp 1 | |
|
76 | If \-tk is given, IPython will try to coordinate Tk threading with GTK, QT or | |
|
77 | WX. This is however potentially unreliable, and you will have to test on your | |
|
78 | platform and Python configuration to determine whether it works for you. | |
|
79 | Debian users have reported success, apparently due to the fact that Debian | |
|
80 | builds all of Tcl, Tk, Tkinter and Python with pthreads support. Under other | |
|
81 | Linux environments (such as Fedora Core 2), this option has caused random | |
|
82 | crashes and lockups of the Python interpreter. Under other operating systems | |
|
83 | (Mac OSX and Windows), you'll need to try it to find out, since currently no | |
|
84 | user reports are available. | |
|
85 | .br | |
|
86 | .sp 1 | |
|
87 | There is unfortunately no way for IPython to determine at runtime whether \-tk | |
|
88 | will work reliably or not, so you will need to do some experiments before | |
|
89 | relying on it for regular work. | |
|
90 | 34 | . |
|
91 | 35 | .SH REGULAR OPTIONS |
|
92 | 36 | After the above threading options have been given, regular options can follow |
|
93 | 37 | in any order. All options can be abbreviated to their shortest non-ambiguous |
|
94 | 38 | form and are case-sensitive. One or two dashes can be used. Some options |
|
95 | 39 | have an alternate short form, indicated after a |. |
|
96 | 40 | .br |
|
97 | 41 | .sp 1 |
|
98 | 42 | Most options can also be set from your ipythonrc configuration file. |
|
99 | 43 | See the provided examples for assistance. Options given on the |
|
100 | 44 | commandline override the values set in the ipythonrc file. |
|
101 | 45 | .br |
|
102 | 46 | .sp 1 |
|
103 | 47 | All options with a [no] prepended can be specified in negated form |
|
104 | 48 | (\-nooption instead of \-option) to turn the feature off. |
|
105 | 49 | .TP |
|
106 | 50 | .B \-h, \-\-help |
|
107 | 51 | Show summary of options. |
|
108 | 52 | .TP |
|
109 | 53 | .B \-autocall <val> |
|
110 | 54 | Make IPython automatically call any callable object even if you didn't type |
|
111 | 55 | explicit parentheses. For example, 'str 43' becomes |
|
112 | 56 | str(43) automatically. The value can be '0' to disable the |
|
113 | 57 | feature, '1' for 'smart' autocall, where it is not applied if |
|
114 | 58 | there are no more arguments on the line, and '2' for 'full' |
|
115 | 59 | autocall, where all callable objects are automatically called |
|
116 | 60 | (even if no arguments are present). The default is '1'. |
|
117 | 61 | .TP |
|
118 | 62 | .B \-[no]autoindent |
|
119 | 63 | Turn automatic indentation on/off. |
|
120 | 64 | .TP |
|
121 | 65 | .B \-[no]automagic |
|
122 | 66 | Make magic commands automatic (without needing their first character |
|
123 | 67 | to be %). Type %magic at the IPython prompt for more information. |
|
124 | 68 | .TP |
|
125 | 69 | .B \-[no]autoedit_syntax |
|
126 | 70 | When a syntax error occurs after editing a file, automatically open the file |
|
127 | 71 | to the trouble causing line for convenient fixing. |
|
128 | 72 | .TP |
|
129 | 73 | .B \-[no]banner |
|
130 | 74 | Print the intial information banner (default on). |
|
131 | 75 | .TP |
|
132 | 76 | .B \-c <command> |
|
133 | 77 | Execute the given command string, and set sys.argv to ['c']. This is similar |
|
134 | 78 | to the \-c option in the normal Python interpreter. |
|
135 | 79 | .TP |
|
136 | 80 | .B \-cache_size|cs <n> |
|
137 | 81 | Size of the output cache (maximum number of entries to hold in |
|
138 | 82 | memory). The default is 1000, you can change it permanently in your |
|
139 | 83 | config file. Setting it to 0 completely disables the caching system, |
|
140 | 84 | and the minimum value accepted is 20 (if you provide a value less than |
|
141 | 85 | 20, it is reset to 0 and a warning is issued). This limit is defined |
|
142 | 86 | because otherwise you'll spend more time re-flushing a too small cache |
|
143 | 87 | than working. |
|
144 | 88 | .TP |
|
145 | 89 | .B \-classic|cl |
|
146 | 90 | Gives IPython a similar feel to the classic Python prompt. |
|
147 | 91 | .TP |
|
148 | 92 | .B \-colors <scheme> |
|
149 | 93 | Color scheme for prompts and exception reporting. Currently |
|
150 | 94 | implemented: NoColor, Linux, and LightBG. |
|
151 | 95 | .TP |
|
152 | 96 | .B \-[no]color_info |
|
153 | 97 | IPython can display information about objects via a set of functions, |
|
154 | 98 | and optionally can use colors for this, syntax highlighting source |
|
155 | 99 | code and various other elements. However, because this information is |
|
156 | 100 | passed through a pager (like 'less') and many pagers get confused with |
|
157 | 101 | color codes, this option is off by default. You can test it and turn |
|
158 | 102 | it on permanently in your ipythonrc file if it works for you. As a |
|
159 | 103 | reference, the 'less' pager supplied with Mandrake 8.2 works ok, but |
|
160 | 104 | that in RedHat 7.2 doesn't. |
|
161 | 105 | .br |
|
162 | 106 | .sp 1 |
|
163 | 107 | Test it and turn it on permanently if it works with your system. The |
|
164 | 108 | magic function @color_info allows you to toggle this interactively for |
|
165 | 109 | testing. |
|
166 | 110 | .TP |
|
167 | 111 | .B \-[no]confirm_exit |
|
168 | 112 | Set to confirm when you try to exit IPython with an EOF (Control-D in |
|
169 | 113 | Unix, Control-Z/Enter in Windows). Note that using the magic functions |
|
170 | 114 | @Exit or @Quit you can force a direct exit, bypassing any |
|
171 | 115 | confirmation. |
|
172 | 116 | .TP |
|
173 | 117 | .B \-[no]debug |
|
174 | 118 | Show information about the loading process. Very useful to pin down |
|
175 | 119 | problems with your configuration files or to get details about session |
|
176 | 120 | restores. |
|
177 | 121 | .TP |
|
178 | 122 | .B \-[no]deep_reload |
|
179 | 123 | IPython can use the deep_reload module which reloads changes in |
|
180 | 124 | modules recursively (it replaces the reload() function, so you don't |
|
181 | 125 | need to change anything to use it). deep_reload() forces a full reload |
|
182 | 126 | of modules whose code may have changed, which the default reload() |
|
183 | 127 | function does not. |
|
184 | 128 | .br |
|
185 | 129 | .sp 1 |
|
186 | 130 | When deep_reload is off, IPython will use the normal reload(), but |
|
187 | 131 | deep_reload will still be available as dreload(). This feature is off |
|
188 | 132 | by default [which means that you have both normal reload() and |
|
189 | 133 | dreload()]. |
|
190 | 134 | .TP |
|
191 | 135 | .B \-editor <name> |
|
192 | 136 | Which editor to use with the @edit command. By default, IPython will |
|
193 | 137 | honor your EDITOR environment variable (if not set, vi is the Unix |
|
194 | 138 | default and notepad the Windows one). Since this editor is invoked on |
|
195 | 139 | the fly by IPython and is meant for editing small code snippets, you |
|
196 | 140 | may want to use a small, lightweight editor here (in case your default |
|
197 | 141 | EDITOR is something like Emacs). |
|
198 | 142 | .TP |
|
199 | 143 | .B \-ipythondir <name> |
|
200 | 144 | The name of your IPython configuration directory IPYTHONDIR. This can |
|
201 | 145 | also be specified through the environment variable IPYTHONDIR. |
|
202 | 146 | .TP |
|
203 | 147 | .B \-log|l |
|
204 | 148 | Generate a log file of all input. The file is named ipython_log.py in your |
|
205 | 149 | current directory (which prevents logs from multiple IPython sessions from |
|
206 | 150 | trampling each other). You can use this to later restore a session by loading |
|
207 | 151 | your logfile as a file to be executed with option -logplay (see below). |
|
208 | 152 | .TP |
|
209 | 153 | .B \-logfile|lf |
|
210 | 154 | Specify the name of your logfile. |
|
211 | 155 | .TP |
|
212 | 156 | .B \-logplay|lp |
|
213 | 157 | Replay a previous log. For restoring a session as close as possible to |
|
214 | 158 | the state you left it in, use this option (don't just run the |
|
215 | 159 | logfile). With \-logplay, IPython will try to reconstruct the previous |
|
216 | 160 | working environment in full, not just execute the commands in the |
|
217 | 161 | logfile. |
|
218 | 162 | .br |
|
219 | 163 | .sp 1 |
|
220 | 164 | When a session is restored, logging is automatically turned on again |
|
221 | 165 | with the name of the logfile it was invoked with (it is read from the |
|
222 | 166 | log header). So once you've turned logging on for a session, you can |
|
223 | 167 | quit IPython and reload it as many times as you want and it will |
|
224 | 168 | continue to log its history and restore from the beginning every time. |
|
225 | 169 | .br |
|
226 | 170 | .sp 1 |
|
227 | 171 | Caveats: there are limitations in this option. The history variables |
|
228 | 172 | _i*,_* and _dh don't get restored properly. In the future we will try |
|
229 | 173 | to implement full session saving by writing and retrieving a |
|
230 | 174 | snapshot of the memory state of IPython. But our first attempts |
|
231 | 175 | failed because of inherent limitations of Python's Pickle module, so |
|
232 | 176 | this may have to wait. |
|
233 | 177 | .TP |
|
234 | 178 | .B \-[no]messages |
|
235 | 179 | Print messages which IPython collects about its startup process |
|
236 | 180 | (default on). |
|
237 | 181 | .TP |
|
238 | 182 | .B \-[no]pdb |
|
239 | 183 | Automatically call the pdb debugger after every uncaught exception. If |
|
240 | 184 | you are used to debugging using pdb, this puts you automatically |
|
241 | 185 | inside of it after any call (either in IPython or in code called by |
|
242 | 186 | it) which triggers an exception which goes uncaught. |
|
243 | 187 | .TP |
|
244 | 188 | .B \-pydb |
|
245 | 189 | Makes IPython use the third party "pydb" package as debugger, |
|
246 | 190 | instead of pdb. Requires that pydb is installed. |
|
247 | 191 | .TP |
|
248 | 192 | .B \-[no]pprint |
|
249 | 193 | IPython can optionally use the pprint (pretty printer) module for |
|
250 | 194 | displaying results. pprint tends to give a nicer display of nested |
|
251 | 195 | data structures. If you like it, you can turn it on permanently in |
|
252 | 196 | your config file (default off). |
|
253 | 197 | .TP |
|
254 | 198 | .B \-profile|p <name> |
|
255 | 199 | Assume that your config file is ipythonrc-<name> (looks in current dir |
|
256 | 200 | first, then in IPYTHONDIR). This is a quick way to keep and load |
|
257 | 201 | multiple config files for different tasks, especially if you use the |
|
258 | 202 | include option of config files. You can keep a basic |
|
259 | 203 | IPYTHONDIR/ipythonrc file and then have other 'profiles' which include |
|
260 | 204 | this one and load extra things for particular tasks. For example: |
|
261 | 205 | .br |
|
262 | 206 | .sp 1 |
|
263 | 207 | 1) $HOME/.ipython/ipythonrc : load basic things you always want. |
|
264 | 208 | .br |
|
265 | 209 | 2) $HOME/.ipython/ipythonrc-math : load (1) and basic math-related |
|
266 | 210 | modules. |
|
267 | 211 | .br |
|
268 | 212 | 3) $HOME/.ipython/ipythonrc-numeric : load (1) and Numeric and |
|
269 | 213 | plotting modules. |
|
270 | 214 | .br |
|
271 | 215 | .sp 1 |
|
272 | 216 | Since it is possible to create an endless loop by having circular file |
|
273 | 217 | inclusions, IPython will stop if it reaches 15 recursive inclusions. |
|
274 | 218 | .TP |
|
275 | 219 | .B \-prompt_in1|pi1 <string> |
|
276 | 220 | Specify the string used for input prompts. Note that if you are using |
|
277 | 221 | numbered prompts, the number is represented with a '\\#' in the |
|
278 | 222 | string. Don't forget to quote strings with spaces embedded in |
|
279 | 223 | them. Default: 'In [\\#]: '. |
|
280 | 224 | .br |
|
281 | 225 | .sp 1 |
|
282 | 226 | Most bash-like escapes can be used to customize IPython's prompts, as well as |
|
283 | 227 | a few additional ones which are IPython-specific. All valid prompt escapes |
|
284 | 228 | are described in detail in the Customization section of the IPython HTML/PDF |
|
285 | 229 | manual. |
|
286 | 230 | .TP |
|
287 | 231 | .B \-prompt_in2|pi2 <string> |
|
288 | 232 | Similar to the previous option, but used for the continuation prompts. The |
|
289 | 233 | special sequence '\\D' is similar to '\\#', but with all digits replaced dots |
|
290 | 234 | (so you can have your continuation prompt aligned with your input |
|
291 | 235 | prompt). Default: ' .\\D.: ' (note three spaces at the start for alignment |
|
292 | 236 | with 'In [\\#]'). |
|
293 | 237 | .TP |
|
294 | 238 | .B \-prompt_out|po <string> |
|
295 | 239 | String used for output prompts, also uses numbers like prompt_in1. |
|
296 | 240 | Default: 'Out[\\#]:'. |
|
297 | 241 | .TP |
|
298 | 242 | .B \-quick |
|
299 | 243 | Start in bare bones mode (no config file loaded). |
|
300 | 244 | .TP |
|
301 | 245 | .B \-rcfile <name> |
|
302 | 246 | Name of your IPython resource configuration file. normally IPython |
|
303 | 247 | loads ipythonrc (from current directory) or IPYTHONDIR/ipythonrc. If |
|
304 | 248 | the loading of your config file fails, IPython starts with a bare |
|
305 | 249 | bones configuration (no modules loaded at all). |
|
306 | 250 | .TP |
|
307 | 251 | .B \-[no]readline |
|
308 | 252 | Use the readline library, which is needed to support name completion |
|
309 | 253 | and command history, among other things. It is enabled by default, but |
|
310 | 254 | may cause problems for users of X/Emacs in Python comint or shell |
|
311 | 255 | buffers. |
|
312 | 256 | .br |
|
313 | 257 | .sp 1 |
|
314 | 258 | Note that emacs 'eterm' buffers (opened with M-x term) support |
|
315 | 259 | IPython's readline and syntax coloring fine, only 'emacs' (M-x shell |
|
316 | 260 | and C-c !) buffers do not. |
|
317 | 261 | .TP |
|
318 | 262 | .B \-screen_length|sl <n> |
|
319 | 263 | Number of lines of your screen. This is used to control printing of |
|
320 | 264 | very long strings. Strings longer than this number of lines will be |
|
321 | 265 | sent through a pager instead of directly printed. |
|
322 | 266 | .br |
|
323 | 267 | .sp 1 |
|
324 | 268 | The default value for this is 0, which means IPython will auto-detect |
|
325 | 269 | your screen size every time it needs to print certain potentially long |
|
326 | 270 | strings (this doesn't change the behavior of the 'print' keyword, it's |
|
327 | 271 | only triggered internally). If for some reason this isn't working well |
|
328 | 272 | (it needs curses support), specify it yourself. Otherwise don't change |
|
329 | 273 | the default. |
|
330 | 274 | .TP |
|
331 | 275 | .B \-separate_in|si <string> |
|
332 | 276 | Separator before input prompts. Default '\n'. |
|
333 | 277 | .TP |
|
334 | 278 | .B \-separate_out|so <string> |
|
335 | 279 | Separator before output prompts. Default: 0 (nothing). |
|
336 | 280 | .TP |
|
337 | 281 | .B \-separate_out2|so2 <string> |
|
338 | 282 | Separator after output prompts. Default: 0 (nothing). |
|
339 | 283 | .TP |
|
340 | 284 | .B \-nosep |
|
341 | 285 | Shorthand for '\-separate_in 0 \-separate_out 0 \-separate_out2 0'. |
|
342 | 286 | Simply removes all input/output separators. |
|
343 | 287 | .TP |
|
344 | 288 | .B \-upgrade |
|
345 | 289 | Allows you to upgrade your IPYTHONDIR configuration when you install a |
|
346 | 290 | new version of IPython. Since new versions may include new command |
|
347 | 291 | lines options or example files, this copies updated ipythonrc-type |
|
348 | 292 | files. However, it backs up (with a .old extension) all files which |
|
349 | 293 | it overwrites so that you can merge back any custimizations you might |
|
350 | 294 | have in your personal files. |
|
351 | 295 | .TP |
|
352 | 296 | .B \-Version |
|
353 | 297 | Print version information and exit. |
|
354 | 298 | .TP |
|
355 | 299 | .B -wxversion <string> |
|
356 | 300 | Select a specific version of wxPython (used in conjunction with |
|
357 | 301 | \-wthread). Requires the wxversion module, part of recent wxPython |
|
358 | 302 | distributions. |
|
359 | 303 | .TP |
|
360 | 304 | .B \-xmode <modename> |
|
361 | 305 | Mode for exception reporting. The valid modes are Plain, Context, and |
|
362 | 306 | Verbose. |
|
363 | 307 | .br |
|
364 | 308 | .sp 1 |
|
365 | 309 | \- Plain: similar to python's normal traceback printing. |
|
366 | 310 | .br |
|
367 | 311 | .sp 1 |
|
368 | 312 | \- Context: prints 5 lines of context source code around each line in the |
|
369 | 313 | traceback. |
|
370 | 314 | .br |
|
371 | 315 | .sp 1 |
|
372 | 316 | \- Verbose: similar to Context, but additionally prints the variables |
|
373 | 317 | currently visible where the exception happened (shortening their strings if |
|
374 | 318 | too long). This can potentially be very slow, if you happen to have a huge |
|
375 | 319 | data structure whose string representation is complex to compute. Your |
|
376 | 320 | computer may appear to freeze for a while with cpu usage at 100%. If this |
|
377 | 321 | occurs, you can cancel the traceback with Ctrl-C (maybe hitting it more than |
|
378 | 322 | once). |
|
379 | 323 | . |
|
380 | 324 | .SH EMBEDDING |
|
381 | 325 | It is possible to start an IPython instance inside your own Python |
|
382 | 326 | programs. In the documentation example files there are some |
|
383 | 327 | illustrations on how to do this. |
|
384 | 328 | .br |
|
385 | 329 | .sp 1 |
|
386 | 330 | This feature allows you to evalutate dynamically the state of your |
|
387 | 331 | code, operate with your variables, analyze them, etc. Note however |
|
388 | 332 | that any changes you make to values while in the shell do NOT |
|
389 | 333 | propagate back to the running code, so it is safe to modify your |
|
390 | 334 | values because you won't break your code in bizarre ways by doing so. |
|
391 | 335 | .SH AUTHOR |
|
392 | 336 | IPython was written by Fernando Perez <fperez@colorado.edu>, based on earlier |
|
393 | 337 | code by Janko Hauser <jh@comunit.de> and Nathaniel Gray |
|
394 | 338 | <n8gray@caltech.edu>. This manual page was written by Jack Moffitt |
|
395 | 339 | <jack@xiph.org>, for the Debian project (but may be used by others). |
@@ -1,106 +1,102 | |||
|
1 | 1 | #!python |
|
2 | 2 | """Windows-specific part of the installation""" |
|
3 | 3 | |
|
4 | 4 | import os, sys, shutil |
|
5 | 5 | pjoin = os.path.join |
|
6 | 6 | |
|
7 | 7 | def mkshortcut(target,description,link_file,*args,**kw): |
|
8 | 8 | """make a shortcut if it doesn't exist, and register its creation""" |
|
9 | 9 | |
|
10 | 10 | create_shortcut(target, description, link_file,*args,**kw) |
|
11 | 11 | file_created(link_file) |
|
12 | 12 | |
|
13 | 13 | def install(): |
|
14 | 14 | """Routine to be run by the win32 installer with the -install switch.""" |
|
15 | 15 | |
|
16 | 16 | from IPython.core.release import version |
|
17 | 17 | |
|
18 | 18 | # Get some system constants |
|
19 | 19 | prefix = sys.prefix |
|
20 | 20 | python = pjoin(prefix, 'python.exe') |
|
21 | 21 | |
|
22 | 22 | # Lookup path to common startmenu ... |
|
23 | 23 | ip_start_menu = pjoin(get_special_folder_path('CSIDL_COMMON_PROGRAMS'), 'IPython') |
|
24 | 24 | # Create IPython entry ... |
|
25 | 25 | if not os.path.isdir(ip_start_menu): |
|
26 | 26 | os.mkdir(ip_start_menu) |
|
27 | 27 | directory_created(ip_start_menu) |
|
28 | 28 | |
|
29 | 29 | # Create .py and .bat files to make things available from |
|
30 | 30 | # the Windows command line. Thanks to the Twisted project |
|
31 | 31 | # for this logic! |
|
32 | 32 | programs = [ |
|
33 | 33 | 'ipython', |
|
34 | 34 | 'iptest', |
|
35 | 35 | 'ipcontroller', |
|
36 | 36 | 'ipengine', |
|
37 | 37 | 'ipcluster', |
|
38 | 38 | 'ipythonx', |
|
39 | 39 | 'ipython-wx', |
|
40 | 40 | 'irunner' |
|
41 | 41 | ] |
|
42 | 42 | scripts = pjoin(prefix,'scripts') |
|
43 | 43 | for program in programs: |
|
44 | 44 | raw = pjoin(scripts, program) |
|
45 | 45 | bat = raw + '.bat' |
|
46 | 46 | py = raw + '.py' |
|
47 | 47 | # Create .py versions of the scripts |
|
48 | 48 | shutil.copy(raw, py) |
|
49 | 49 | # Create .bat files for each of the scripts |
|
50 | 50 | bat_file = file(bat,'w') |
|
51 | 51 | bat_file.write("@%s %s %%*" % (python, py)) |
|
52 | 52 | bat_file.close() |
|
53 | 53 | |
|
54 | 54 | # Now move onto setting the Start Menu up |
|
55 | 55 | ipybase = pjoin(scripts, 'ipython') |
|
56 | 56 | |
|
57 | 57 | link = pjoin(ip_start_menu, 'IPython.lnk') |
|
58 | 58 | cmd = '"%s"' % ipybase |
|
59 | 59 | mkshortcut(python,'IPython',link,cmd) |
|
60 | 60 | |
|
61 | 61 | link = pjoin(ip_start_menu, 'pysh.lnk') |
|
62 | 62 | cmd = '"%s" -p sh' % ipybase |
|
63 | 63 | mkshortcut(python,'IPython (command prompt mode)',link,cmd) |
|
64 | 64 | |
|
65 | link = pjoin(ip_start_menu, 'pylab.lnk') | |
|
66 | cmd = '"%s" -pylab' % ipybase | |
|
67 | mkshortcut(python,'IPython (PyLab mode)',link,cmd) | |
|
68 | ||
|
69 | 65 | link = pjoin(ip_start_menu, 'scipy.lnk') |
|
70 |
cmd = '"%s" |
|
|
66 | cmd = '"%s" -p scipy' % ipybase | |
|
71 | 67 | mkshortcut(python,'IPython (scipy profile)',link,cmd) |
|
72 | 68 | |
|
73 | 69 | link = pjoin(ip_start_menu, 'IPython test suite.lnk') |
|
74 | 70 | cmd = '"%s" -vv' % pjoin(scripts, 'iptest') |
|
75 | 71 | mkshortcut(python,'Run the IPython test suite',link,cmd) |
|
76 | 72 | |
|
77 | 73 | link = pjoin(ip_start_menu, 'ipcontroller.lnk') |
|
78 | 74 | cmd = '"%s" -xy' % pjoin(scripts, 'ipcontroller') |
|
79 | 75 | mkshortcut(python,'IPython controller',link,cmd) |
|
80 | 76 | |
|
81 | 77 | link = pjoin(ip_start_menu, 'ipengine.lnk') |
|
82 | 78 | cmd = '"%s"' % pjoin(scripts, 'ipengine') |
|
83 | 79 | mkshortcut(python,'IPython engine',link,cmd) |
|
84 | 80 | |
|
85 | 81 | # Create documentation shortcuts ... |
|
86 | 82 | t = prefix + r'\share\doc\ipython\manual\ipython.pdf' |
|
87 | 83 | f = ip_start_menu + r'\Manual in PDF.lnk' |
|
88 | 84 | mkshortcut(t,r'IPython Manual - PDF-Format',f) |
|
89 | 85 | |
|
90 | 86 | t = prefix + r'\share\doc\ipython\manual\html\index.html' |
|
91 | 87 | f = ip_start_menu + r'\Manual in HTML.lnk' |
|
92 | 88 | mkshortcut(t,'IPython Manual - HTML-Format',f) |
|
93 | 89 | |
|
94 | 90 | |
|
95 | 91 | def remove(): |
|
96 | 92 | """Routine to be run by the win32 installer with the -remove switch.""" |
|
97 | 93 | pass |
|
98 | 94 | |
|
99 | 95 | # main() |
|
100 | 96 | if len(sys.argv) > 1: |
|
101 | 97 | if sys.argv[1] == '-install': |
|
102 | 98 | install() |
|
103 | 99 | elif sys.argv[1] == '-remove': |
|
104 | 100 | remove() |
|
105 | 101 | else: |
|
106 | 102 | print "Script was called with option %s" % sys.argv[1] |
|
1 | NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now