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