##// END OF EJS Templates
Fix incorrect link in OSX instructions.
fperez -
Show More
@@ -1,8818 +1,8819 b''
1 1 #LyX 1.3 created this file. For more info see http://www.lyx.org/
2 2 \lyxformat 221
3 3 \textclass article
4 4 \begin_preamble
5 5 \usepackage{ae,aecompl}
6 6 \usepackage{hyperref}
7 7 \usepackage{html}
8 8 \end_preamble
9 9 \language english
10 10 \inputencoding latin1
11 11 \fontscheme default
12 12 \graphics default
13 13 \paperfontsize default
14 14 \spacing single
15 15 \papersize Default
16 16 \paperpackage a4
17 17 \use_geometry 1
18 18 \use_amsmath 0
19 19 \use_natbib 0
20 20 \use_numerical_citations 0
21 21 \paperorientation portrait
22 22 \leftmargin 1.25in
23 23 \topmargin 1in
24 24 \rightmargin 1.25in
25 25 \bottommargin 1in
26 26 \secnumdepth 3
27 27 \tocdepth 3
28 28 \paragraph_separation skip
29 29 \defskip medskip
30 30 \quotes_language english
31 31 \quotes_times 2
32 32 \papercolumns 1
33 33 \papersides 1
34 34 \paperpagestyle fancy
35 35
36 36 \layout Title
37 37
38 38 IPython
39 39 \newline
40 40
41 41 \size larger
42 42 An enhanced Interactive Python
43 43 \size large
44 44
45 45 \newline
46 46 User Manual, v.
47 47 __version__
48 48 \layout Author
49 49
50 50 Fernando PοΏ½rez
51 51 \layout Standard
52 52
53 53
54 54 \begin_inset ERT
55 55 status Collapsed
56 56
57 57 \layout Standard
58 58
59 59 \backslash
60 60 latex{
61 61 \end_inset
62 62
63 63
64 64 \begin_inset LatexCommand \tableofcontents{}
65 65
66 66 \end_inset
67 67
68 68
69 69 \begin_inset ERT
70 70 status Collapsed
71 71
72 72 \layout Standard
73 73 }
74 74 \end_inset
75 75
76 76
77 77 \layout Standard
78 78
79 79
80 80 \begin_inset ERT
81 81 status Open
82 82
83 83 \layout Standard
84 84
85 85 \backslash
86 86 html{
87 87 \backslash
88 88 bodytext{bgcolor=#ffffff}}
89 89 \end_inset
90 90
91 91
92 92 \layout Section
93 93 \pagebreak_top
94 94 Overview
95 95 \layout Standard
96 96
97 97 One of Python's most useful features is its interactive interpreter.
98 98 This system allows very fast testing of ideas without the overhead of creating
99 99 test files as is typical in most programming languages.
100 100 However, the interpreter supplied with the standard Python distribution
101 101 is somewhat limited for extended interactive use.
102 102 \layout Standard
103 103
104 104 IPython is a free software project (released under the BSD license) which
105 105 tries to:
106 106 \layout Enumerate
107 107
108 108 Provide an interactive shell superior to Python's default.
109 109 IPython has many features for object introspection, system shell access,
110 110 and its own special command system for adding functionality when working
111 111 interactively.
112 112 It tries to be a very efficient environment both for Python code development
113 113 and for exploration of problems using Python objects (in situations like
114 114 data analysis).
115 115 \layout Enumerate
116 116
117 117 Serve as an embeddable, ready to use interpreter for your own programs.
118 118 IPython can be started with a single call from inside another program,
119 119 providing access to the current namespace.
120 120 This can be very useful both for debugging purposes and for situations
121 121 where a blend of batch-processing and interactive exploration are needed.
122 122 \layout Enumerate
123 123
124 124 Offer a flexible framework which can be used as the base environment for
125 125 other systems with Python as the underlying language.
126 126 Specifically scientific environments like Mathematica, IDL and Matlab inspired
127 127 its design, but similar ideas can be useful in many fields.
128 128 \layout Subsection
129 129
130 130 Main features
131 131 \layout Itemize
132 132
133 133 Dynamic object introspection.
134 134 One can access docstrings, function definition prototypes, source code,
135 135 source files and other details of any object accessible to the interpreter
136 136 with a single keystroke (`
137 137 \family typewriter
138 138 ?
139 139 \family default
140 140 ').
141 141 \layout Itemize
142 142
143 143 Completion in the local namespace, by typing TAB at the prompt.
144 144 This works for keywords, methods, variables and files in the current directory.
145 145 This is supported via the readline library, and full access to configuring
146 146 readline's behavior is provided.
147 147 \layout Itemize
148 148
149 149 Numbered input/output prompts with command history (persistent across sessions
150 150 and tied to each profile), full searching in this history and caching of
151 151 all input and output.
152 152 \layout Itemize
153 153
154 154 User-extensible `magic' commands.
155 155 A set of commands prefixed with
156 156 \family typewriter
157 157 %
158 158 \family default
159 159 is available for controlling IPython itself and provides directory control,
160 160 namespace information and many aliases to common system shell commands.
161 161 \layout Itemize
162 162
163 163 Alias facility for defining your own system aliases.
164 164 \layout Itemize
165 165
166 166 Complete system shell access.
167 167 Lines starting with ! are passed directly to the system shell, and using
168 168 !! captures shell output into python variables for further use.
169 169 \layout Itemize
170 170
171 171 All calls to the system (via aliases or via !) have their standard output/error
172 172 automatically stored as strings, and also available as lists.
173 173 \layout Itemize
174 174
175 175 Background execution of Python commands in a separate thread.
176 176 IPython has an internal job manager called
177 177 \family typewriter
178 178 jobs
179 179 \family default
180 180 , and a conveninence backgrounding magic function called
181 181 \family typewriter
182 182 %bg
183 183 \family default
184 184 .
185 185 \layout Itemize
186 186
187 187 The ability to expand python variables when calling the system shell.
188 188 In a shell command, any python variable prefixed with
189 189 \family typewriter
190 190 $
191 191 \family default
192 192 is expanded.
193 193 A double
194 194 \family typewriter
195 195 $$
196 196 \family default
197 197 allows passing a literal
198 198 \family typewriter
199 199 $
200 200 \family default
201 201 to the shell (for access to shell and environment variables like
202 202 \family typewriter
203 203 $PATH
204 204 \family default
205 205 ).
206 206 \layout Itemize
207 207
208 208 Filesystem navigation, via a magic
209 209 \family typewriter
210 210 %cd
211 211 \family default
212 212 command, along with a persistent bookmark system (using
213 213 \family typewriter
214 214 %bookmark
215 215 \family default
216 216 ) for fast access to frequently visited directories.
217 217 \layout Itemize
218 218
219 219 Automatic indentation (optional) of code as you type (through the readline
220 220 library).
221 221 \layout Itemize
222 222
223 223 Macro system for quickly re-executing multiple lines of previous input with
224 224 a single name.
225 225 \layout Itemize
226 226
227 227 Session logging (you can then later use these logs as code in your programs).
228 228 \layout Itemize
229 229
230 230 Session restoring: logs can be replayed to restore a previous session to
231 231 the state where you left it.
232 232 \layout Itemize
233 233
234 234 Verbose and colored exception traceback printouts.
235 235 Easier to parse visually, and in verbose mode they produce a lot of useful
236 236 debugging information (basically a terminal version of the cgitb module).
237 237 \layout Itemize
238 238
239 239 Auto-parentheses: callable objects can be executed without parentheses:
240 240
241 241 \family typewriter
242 242 `sin 3'
243 243 \family default
244 244 is automatically converted to
245 245 \family typewriter
246 246 `sin(3)
247 247 \family default
248 248 '.
249 249 \layout Itemize
250 250
251 251 Auto-quoting: using `
252 252 \family typewriter
253 253 ,
254 254 \family default
255 255 ' or `
256 256 \family typewriter
257 257 ;
258 258 \family default
259 259 ' as the first character forces auto-quoting of the rest of the line:
260 260 \family typewriter
261 261 `,my_function a\SpecialChar ~
262 262 b'
263 263 \family default
264 264 becomes automatically
265 265 \family typewriter
266 266 `my_function("a","b")'
267 267 \family default
268 268 , while
269 269 \family typewriter
270 270 `;my_function a\SpecialChar ~
271 271 b'
272 272 \family default
273 273 becomes
274 274 \family typewriter
275 275 `my_function("a b")'
276 276 \family default
277 277 .
278 278 \layout Itemize
279 279
280 280 Extensible input syntax.
281 281 You can define filters that pre-process user input to simplify input in
282 282 special situations.
283 283 This allows for example pasting multi-line code fragments which start with
284 284
285 285 \family typewriter
286 286 `>>>'
287 287 \family default
288 288 or
289 289 \family typewriter
290 290 `...'
291 291 \family default
292 292 such as those from other python sessions or the standard Python documentation.
293 293 \layout Itemize
294 294
295 295 Flexible configuration system.
296 296 It uses a configuration file which allows permanent setting of all command-line
297 297 options, module loading, code and file execution.
298 298 The system allows recursive file inclusion, so you can have a base file
299 299 with defaults and layers which load other customizations for particular
300 300 projects.
301 301 \layout Itemize
302 302
303 303 Embeddable.
304 304 You can call IPython as a python shell inside your own python programs.
305 305 This can be used both for debugging code or for providing interactive abilities
306 306 to your programs with knowledge about the local namespaces (very useful
307 307 in debugging and data analysis situations).
308 308 \layout Itemize
309 309
310 310 Easy debugger access.
311 311 You can set IPython to call up the Python debugger (pdb) every time there
312 312 is an uncaught exception.
313 313 This drops you inside the code which triggered the exception with all the
314 314 data live and it is possible to navigate the stack to rapidly isolate the
315 315 source of a bug.
316 316 The
317 317 \family typewriter
318 318 %run
319 319 \family default
320 320 magic command --with the
321 321 \family typewriter
322 322 -d
323 323 \family default
324 324 option-- can run any script under
325 325 \family typewriter
326 326 pdb
327 327 \family default
328 328 's control, automatically setting initial breakpoints for you.
329 329 \layout Itemize
330 330
331 331 Profiler support.
332 332 You can run single statements (similar to
333 333 \family typewriter
334 334 profile.run()
335 335 \family default
336 336 ) or complete programs under the profiler's control.
337 337 While this is possible with the standard
338 338 \family typewriter
339 339 profile
340 340 \family default
341 341 module, IPython wraps this functionality with magic commands (see
342 342 \family typewriter
343 343 `%prun'
344 344 \family default
345 345 and
346 346 \family typewriter
347 347 `%run -p
348 348 \family default
349 349 ') convenient for rapid interactive work.
350 350 \layout Subsection
351 351
352 352 Portability and Python requirements
353 353 \layout Standard
354 354
355 355
356 356 \series bold
357 357 Python requirements:
358 358 \series default
359 359 IPython works with Python version 2.2 or newer.
360 360 It has been tested with Python 2.4 and no problems have been reported.
361 361 Support for Python 2.1 hasn't been recently tested, since I don't have access
362 362 to it on any of my systems.
363 363 But I suspect there may be some problems with Python 2.1, because some of
364 364 the newer code may use 2.2 features.
365 365 \layout Standard
366 366
367 367 IPython is developed under
368 368 \series bold
369 369 Linux
370 370 \series default
371 371 , but it should work in any reasonable Unix-type system (tested OK under
372 372 Solaris and the *BSD family, for which a port exists thanks to Dryice Liu).
373 373 \layout Standard
374 374
375 375
376 376 \series bold
377 377 Mac OS X
378 378 \series default
379 379 : it works, apparently without any problems (thanks to Jim Boyle at Lawrence
380 380 Livermore for the information).
381 381 Thanks to Andrea Riciputi, Fink support is available.
382 382 \layout Standard
383 383
384 384
385 385 \series bold
386 386 CygWin
387 387 \series default
388 388 : it works mostly OK, though some users have reported problems with prompt
389 389 coloring.
390 390 No satisfactory solution to this has been found so far, you may want to
391 391 disable colors permanently in the
392 392 \family typewriter
393 393 ipythonrc
394 394 \family default
395 395 configuration file if you experience problems.
396 396 If you have proper color support under cygwin, please post to the IPython
397 397 mailing list so this issue can be resolved for all users.
398 398 \layout Standard
399 399
400 400
401 401 \series bold
402 402 Windows
403 403 \series default
404 404 : it works well under Windows XP/2k, and I suspect NT should behave similarly.
405 405 Section\SpecialChar ~
406 406
407 407 \begin_inset LatexCommand \ref{sub:Under-Windows}
408 408
409 409 \end_inset
410 410
411 411 describes installation details for Windows, including some additional tools
412 412 needed on this platform.
413 413 \layout Standard
414 414
415 415 Windows 9x support is present, and has been reported to work fine (at least
416 416 on WinME).
417 417 \layout Standard
418 418
419 419 Please note, however, that I have very little access to and experience with
420 420 Windows development.
421 421 For this reason, Windows-specific bugs tend to linger far longer than I
422 422 would like, and often I just can't find a satisfactory solution.
423 423 If any Windows user wants to join in with development help, all hands are
424 424 always welcome.
425 425 \layout Subsection
426 426
427 427 Location
428 428 \layout Standard
429 429
430 430 IPython is generously hosted at
431 431 \begin_inset LatexCommand \htmlurl{http://ipython.scipy.org}
432 432
433 433 \end_inset
434 434
435 435 by the SciPy project.
436 436 This site offers downloads, CVS access, mailing lists and a bug tracking
437 437 system.
438 438 I am very grateful to Enthought (
439 439 \begin_inset LatexCommand \htmlurl{http://www.enthought.com}
440 440
441 441 \end_inset
442 442
443 443 ) and all of the SciPy team for their contribution.
444 444 \layout Section
445 445
446 446
447 447 \begin_inset LatexCommand \label{sec:install}
448 448
449 449 \end_inset
450 450
451 451 Installation
452 452 \layout Subsection
453 453
454 454 Instant instructions
455 455 \layout Standard
456 456
457 457 If you are of the impatient kind, under Linux/Unix simply untar/unzip the
458 458 download, then install with
459 459 \family typewriter
460 460 `python setup.py install'
461 461 \family default
462 462 .
463 463 Under Windows, double-click on the provided
464 464 \family typewriter
465 465 .exe
466 466 \family default
467 467 binary installer.
468 468 \layout Standard
469 469
470 470 Then, take a look at Sections
471 471 \begin_inset LatexCommand \ref{sec:good_config}
472 472
473 473 \end_inset
474 474
475 475 for configuring things optimally and
476 476 \begin_inset LatexCommand \ref{sec:quick_tips}
477 477
478 478 \end_inset
479 479
480 480 for quick tips on efficient use of IPython.
481 481 You can later refer to the rest of the manual for all the gory details.
482 482 \layout Standard
483 483
484 484 See the notes in sec.
485 485
486 486 \begin_inset LatexCommand \ref{sec:upgrade}
487 487
488 488 \end_inset
489 489
490 490 for upgrading IPython versions.
491 491 \layout Subsection
492 492
493 493 Detailed Unix instructions (Linux, Mac OS X, etc.)
494 494 \layout Standard
495 495
496 496
497 497 \begin_inset ERT
498 498 status Open
499 499
500 500 \layout Standard
501 501
502 502 \backslash
503 503 html{
504 504 \backslash
505 505 textbf{A warning to readers of the HTML version of this manual}: all options below are preceded with with TWO dashes and no intervening space between the dashes (e.g. Dash-Dash-home). The default HTML conversion tools mangle these into a single dash.}
506 506 \end_inset
507 507
508 508
509 509 \layout Standard
510 510
511 511 For RPM based systems, simply install the supplied package in the usual
512 512 manner.
513 513 If you download the tar archive, the process is:
514 514 \layout Enumerate
515 515
516 516 Unzip/untar the
517 517 \family typewriter
518 518 ipython-XXX.tar.gz
519 519 \family default
520 520 file wherever you want (
521 521 \family typewriter
522 522 XXX
523 523 \family default
524 524 is the version number).
525 525 It will make a directory called
526 526 \family typewriter
527 527 ipython-XXX.
528 528
529 529 \family default
530 530 Change into that directory where you will find the files
531 531 \family typewriter
532 532 README
533 533 \family default
534 534 and
535 535 \family typewriter
536 536 setup.py
537 537 \family default
538 538 .
539 539
540 540 \family typewriter
541 541 O
542 542 \family default
543 543 nce you've completed the installation, you can safely remove this directory.
544 544
545 545 \layout Enumerate
546 546
547 547 If you are installing over a previous installation of version 0.2.0 or earlier,
548 548 first remove your
549 549 \family typewriter
550 550 $HOME/.ipython
551 551 \family default
552 552 directory, since the configuration file format has changed somewhat (the
553 553 '=' were removed from all option specifications).
554 554 Or you can call ipython with the
555 555 \family typewriter
556 556 -upgrade
557 557 \family default
558 558 option and it will do this automatically for you.
559 559 \layout Enumerate
560 560
561 561 IPython uses distutils, so you can install it by simply typing at the system
562 562 prompt (don't type the
563 563 \family typewriter
564 564 $
565 565 \family default
566 566 )
567 567 \newline
568 568
569 569 \family typewriter
570 570 $ python setup.py install
571 571 \family default
572 572
573 573 \newline
574 574 Note that this assumes you have root access to your machine.
575 575 If you don't have root access or don't want IPython to go in the default
576 576 python directories, you'll need to use the
577 577 \family typewriter
578 578 --home
579 579 \family default
580 580 option (or
581 581 \family typewriter
582 582 --prefix
583 583 \family default
584 584 ).
585 585 For example:
586 586 \newline
587 587
588 588 \family typewriter
589 589 $ python setup.py install --home $HOME/local
590 590 \family default
591 591
592 592 \newline
593 593 will install
594 594 \begin_inset Foot
595 595 collapsed true
596 596
597 597 \layout Standard
598 598
599 599 If you are reading these instructions in HTML format, please note that the
600 600 option is --home, with
601 601 \emph on
602 602 two
603 603 \emph default
604 604 dashes.
605 605 The automatic HTML conversion program seems to eat up one of the dashes,
606 606 unfortunately (it's ok in the PDF version).
607 607 \end_inset
608 608
609 609 IPython into
610 610 \family typewriter
611 611 $HOME/local
612 612 \family default
613 613 and its subdirectories (creating them if necessary).
614 614 \newline
615 615 You can type
616 616 \newline
617 617
618 618 \family typewriter
619 619 $ python setup.py --help
620 620 \family default
621 621
622 622 \newline
623 623 for more details.
624 624 \newline
625 625 Note that if you change the default location for
626 626 \family typewriter
627 627 --home
628 628 \family default
629 629 at installation, IPython may end up installed at a location which is not
630 630 part of your
631 631 \family typewriter
632 632 $PYTHONPATH
633 633 \family default
634 634 environment variable.
635 635 In this case, you'll need to configure this variable to include the actual
636 636 directory where the
637 637 \family typewriter
638 638 IPython/
639 639 \family default
640 640 directory ended (typically the value you give to
641 641 \family typewriter
642 642 --home
643 643 \family default
644 644 plus
645 645 \family typewriter
646 646 /lib/python
647 647 \family default
648 648 ).
649 649 \layout Subsubsection
650 650
651 651 Mac OSX information
652 652 \layout Standard
653 653
654 654 Under OSX, there is a choice you need to make.
655 655 Apple ships its own build of Python, which lives in the core OSX filesystem
656 656 hierarchy.
657 657 You can also manually install a separate Python, either purely by hand
658 658 (typically in
659 659 \family typewriter
660 660 /usr/local
661 661 \family default
662 662 ) or by using Fink, which puts everything under
663 663 \family typewriter
664 664 /sw
665 665 \family default
666 666 .
667 667 Which route to follow is a matter of personal preference, as I've seen
668 668 users who favor each of the approaches.
669 669 Here I will simply list the known installation issues under OSX, along
670 670 with their solutions.
671 671 \layout Subsubsection*
672 672
673 673 GUI problems
674 674 \layout Standard
675 675
676 676 The following instructions apply to an install of IPython under OSX from
677 677 unpacking the
678 678 \family typewriter
679 679 .tar.gz
680 680 \family default
681 681 distribution and installing it for the default Python interpreter shipped
682 682 by Apple.
683 683 If you are using a fink install, fink will take care of these details for
684 684 you, by installing IPython against fink's Python.
685 685 \layout Standard
686 686
687 687 IPython offers various forms of support for interacting with graphical applicati
688 688 ons from the command line, from simple Tk apps (which are in principle always
689 689 supported by Python) to interactive control of WX, QT and GTK apps.
690 690 Under OSX, however, this requires that ipython is installed by calling
691 691 the special
692 692 \family typewriter
693 693 pythonw
694 694 \family default
695 695 script at installation time, which takes care of coordinating things with
696 696 Apple's graphical environment.
697 697 \layout Standard
698 698
699 699 So when installing under OSX, it is best to use the following command
700 700 \begin_inset ERT
701 701 status Collapsed
702 702
703 703 \layout Standard
704 704
705 705 \backslash
706 706 html{
707 707 \backslash
708 708 emph{[Again, in the HTML manual, the option is called -~-install=scripts, with TWO dashes and no intervening space between the dashes]}}
709 709 \end_inset
710 710
711 711 :
712 712 \family typewriter
713 713
714 714 \newline
715 715 \SpecialChar ~
716 716 \SpecialChar ~
717 717 $ sudo pythonw setup.py install --install-scripts=/usr/local/bin
718 718 \family default
719 719
720 720 \newline
721 721 or
722 722 \family typewriter
723 723
724 724 \newline
725 725 \SpecialChar ~
726 726 \SpecialChar ~
727 727 $ sudo pythonw setup.py install --install-scripts=/usr/bin
728 728 \newline
729 729
730 730 \family default
731 731 depending on where you like to keep hand-installed executables.
732 732 \layout Standard
733 733
734 734 The resulting script will have an appropriate shebang line (the first line
735 735 in the script whic begins with
736 736 \family typewriter
737 737 #!...
738 738 \family default
739 739 ) such that the ipython interpreter can interact with the OS X GUI.
740 740 If the installed version does not work and has a shebang line that points
741 741 to, for example, just
742 742 \family typewriter
743 743 /usr/bin/python
744 744 \family default
745 745 , then you might have a stale, cached version in your
746 746 \family typewriter
747 747 build/scripts-<python-version>
748 748 \family default
749 749 directory.
750 750 Delete that directory and rerun the
751 751 \family typewriter
752 752 setup.py
753 753 \family default
754 754 .
755 755
756 756 \layout Standard
757 757
758 758 It is also a good idea to use the special flag
759 759 \family typewriter
760 760 --install-scripts
761 761 \family default
762 762 as indicated above, to ensure that the ipython scripts end up in a location
763 763 which is part of your
764 764 \family typewriter
765 765 $PATH
766 766 \family default
767 767 .
768 768 Otherwise Apple's Python will put the scripts in an internal directory
769 769 not available by default at the command line (if you use
770 770 \family typewriter
771 771 /usr/local/bin
772 772 \family default
773 773 , you need to make sure this is in your
774 774 \family typewriter
775 775 $PATH
776 776 \family default
777 777 , which may not be true by default).
778 778 \layout Subsubsection*
779 779
780 780 Readline problems
781 781 \layout Standard
782 782
783 783 By default, the Python version shipped by Apple does
784 784 \emph on
785 785 not
786 786 \emph default
787 787 include the readline library, so central to IPython's behavior.
788 788 If you install IPython against Apple's Python, you will not have arrow
789 789 keys, tab completion, etc.
790 790 For Mac OSX 10.3 (Panther), you can find a prebuilt readline library here:
791 791 \newline
792 792
793 793 \begin_inset LatexCommand \htmlurl{http://pythonmac.org/packages/readline-5.0-py2.3-macosx10.3.zip}
794 794
795 795 \end_inset
796 796
797 797
798 798 \layout Standard
799 799
800 Install this package, then you need to either:
800 If you are using OSX 10.4 (Tiger), after installing this package you need
801 to either:
801 802 \layout Enumerate
802 803
803 Move
804 move
804 805 \family typewriter
805 806 readline.so
806 807 \family default
807 808 from
808 809 \family typewriter
809 810 /Library/Python/2.3
810 811 \family default
811 812 to
812 813 \family typewriter
813 814 /Library/Python/2.3/site-packages
814 815 \family default
815 .
816 , or
816 817 \layout Enumerate
817 818
818 Install
819 \begin_inset LatexCommand \htmlurl{http://ipython.scipy.org/tmp/scipy_cvs_2005-07-29.tgz}
819 install
820 \begin_inset LatexCommand \htmlurl{http://pythonmac.org/packages/TigerPython23Compat.pkg.zip}
820 821
821 822 \end_inset
822 823
823 824
824 825 \layout Standard
825 826
826 827 Users installing against Fink's Python or a properly hand-built one should
827 828 not have this problem.
828 829 \layout Subsection
829 830
830 831
831 832 \begin_inset LatexCommand \label{sub:Under-Windows}
832 833
833 834 \end_inset
834 835
835 836 Windows instructions
836 837 \layout Standard
837 838
838 839 While you can use IPython under Windows with only a stock Python installation,
839 840 there is one extension,
840 841 \family typewriter
841 842 readline
842 843 \family default
843 844 , which will make the whole experience a lot more pleasant.
844 845 It is almost a requirement, since IPython will complain in its absence
845 846 (though it will function).
846 847
847 848 \layout Standard
848 849
849 850 The
850 851 \family typewriter
851 852 readline
852 853 \family default
853 854 extension needs two other libraries to work, so in all you need:
854 855 \layout Enumerate
855 856
856 857
857 858 \family typewriter
858 859 PyWin32
859 860 \family default
860 861 from
861 862 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/mhammond}
862 863
863 864 \end_inset
864 865
865 866 .
866 867 \layout Enumerate
867 868
868 869
869 870 \family typewriter
870 871 CTypes
871 872 \family default
872 873 from
873 874 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/theller/ctypes}
874 875
875 876 \end_inset
876 877
877 878 (you
878 879 \emph on
879 880 must
880 881 \emph default
881 882 use version 0.9.1 or newer).
882 883 \layout Enumerate
883 884
884 885
885 886 \family typewriter
886 887 Readline
887 888 \family default
888 889 for Windows from
889 890 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/projects/uncpythontools}
890 891
891 892 \end_inset
892 893
893 894 .
894 895 \layout Standard
895 896
896 897
897 898 \series bold
898 899 Warning about a broken readline-like library:
899 900 \series default
900 901 several users have reported problems stemming from using the pseudo-readline
901 902 library at
902 903 \begin_inset LatexCommand \htmlurl{http://newcenturycomputers.net/projects/readline.html}
903 904
904 905 \end_inset
905 906
906 907 .
907 908 This is a broken library which, while called readline, only implements
908 909 an incomplete subset of the readline API.
909 910 Since it is still called readline, it fools IPython's detection mechanisms
910 911 and causes unpredictable crashes later.
911 912 If you wish to use IPython under Windows, you must NOT use this library,
912 913 which for all purposes is (at least as of version 1.6) terminally broken.
913 914 \layout Subsubsection
914 915
915 916 Gary Bishop's readline and color support for Windows
916 917 \layout Standard
917 918
918 919 Some of IPython's very useful features are:
919 920 \layout Itemize
920 921
921 922 Integrated readline support (Tab-based file, object and attribute completion,
922 923 input history across sessions, editable command line, etc.)
923 924 \layout Itemize
924 925
925 926 Coloring of prompts, code and tracebacks.
926 927 \layout Standard
927 928
928 929 These, by default, are only available under Unix-like operating systems.
929 930 However, thanks to Gary Bishop's work, Windows XP/2k users can also benefit
930 931 from them.
931 932 His readline library implements both GNU readline functionality and color
932 933 support, so that IPython under Windows XP/2k can be as friendly and powerful
933 934 as under Unix-like environments.
934 935 \layout Standard
935 936
936 937 You can find Gary's tools at
937 938 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/projects/uncpythontools}
938 939
939 940 \end_inset
940 941
941 942 ; Gary's
942 943 \family typewriter
943 944 readline
944 945 \family default
945 946 requires in turn the
946 947 \family typewriter
947 948 ctypes
948 949 \family default
949 950 library by Thomas Heller, available at
950 951 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/theller/ctypes}
951 952
952 953 \end_inset
953 954
954 955 , and Mark Hammond's
955 956 \family typewriter
956 957 PyWin32
957 958 \family default
958 959 from
959 960 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/mhammond}
960 961
961 962 \end_inset
962 963
963 964 (
964 965 \family typewriter
965 966 PyWin32
966 967 \family default
967 968 is great for anything Windows-related anyway, so you might as well get
968 969 it).
969 970 \layout Standard
970 971
971 972 Under MS\SpecialChar ~
972 973 Windows, IPython will complain if it can not find this
973 974 \family typewriter
974 975 readline
975 976 \family default
976 977 library at startup and any time the
977 978 \family typewriter
978 979 %colors
979 980 \family default
980 981 command is issued, so you can consider it to be a quasi-requirement.
981 982 \layout Subsubsection
982 983
983 984 Installation procedure
984 985 \layout Standard
985 986
986 987 Once you have the above installed, from the IPython download directory grab
987 988 the
988 989 \family typewriter
989 990 ipython-XXX.win32.exe
990 991 \family default
991 992 file, where
992 993 \family typewriter
993 994 XXX
994 995 \family default
995 996 represents the version number.
996 997 This is a regular windows executable installer, which you can simply double-cli
997 998 ck to install.
998 999 It will add an entry for IPython to your Start Menu, as well as registering
999 1000 IPython in the Windows list of applications, so you can later uninstall
1000 1001 it from the Control Panel.
1001 1002
1002 1003 \layout Standard
1003 1004
1004 1005 IPython tries to install the configuration information in a directory named
1005 1006
1006 1007 \family typewriter
1007 1008 .ipython
1008 1009 \family default
1009 1010 (
1010 1011 \family typewriter
1011 1012 _ipython
1012 1013 \family default
1013 1014 under Windows) located in your `home' directory.
1014 1015 IPython sets this directory by looking for a
1015 1016 \family typewriter
1016 1017 HOME
1017 1018 \family default
1018 1019 environment variable; if such a variable does not exist, it uses
1019 1020 \family typewriter
1020 1021 HOMEDRIVE
1021 1022 \backslash
1022 1023 HOMEPATH
1023 1024 \family default
1024 1025 (these are always defined by Windows).
1025 1026 This typically gives something like
1026 1027 \family typewriter
1027 1028 C:
1028 1029 \backslash
1029 1030 Documents and Settings
1030 1031 \backslash
1031 1032 YourUserName
1032 1033 \family default
1033 1034 , but your local details may vary.
1034 1035 In this directory you will find all the files that configure IPython's
1035 1036 defaults, and you can put there your profiles and extensions.
1036 1037 This directory is automatically added by IPython to
1037 1038 \family typewriter
1038 1039 sys.path
1039 1040 \family default
1040 1041 , so anything you place there can be found by
1041 1042 \family typewriter
1042 1043 import
1043 1044 \family default
1044 1045 statements.
1045 1046 \layout Paragraph
1046 1047
1047 1048 Upgrading
1048 1049 \layout Standard
1049 1050
1050 1051 For an IPython upgrade, you should first uninstall the previous version.
1051 1052 This will ensure that all files and directories (such as the documentation)
1052 1053 which carry embedded version strings in their names are properly removed.
1053 1054 \layout Paragraph
1054 1055
1055 1056 Manual installation under Win32
1056 1057 \layout Standard
1057 1058
1058 1059 In case the automatic installer does not work for some reason, you can download
1059 1060 the
1060 1061 \family typewriter
1061 1062 ipython-XXX.tar.gz
1062 1063 \family default
1063 1064 file, which contains the full IPython source distribution (the popular
1064 1065 WinZip can read
1065 1066 \family typewriter
1066 1067 .tar.gz
1067 1068 \family default
1068 1069 files).
1069 1070 After uncompressing the archive, you can install it at a command terminal
1070 1071 just like any other Python module, by using
1071 1072 \family typewriter
1072 1073 `python setup.py install'
1073 1074 \family default
1074 1075 .
1075 1076
1076 1077 \layout Standard
1077 1078
1078 1079 After the installation, run the supplied
1079 1080 \family typewriter
1080 1081 win32_manual_post_install.py
1081 1082 \family default
1082 1083 script, which creates the necessary Start Menu shortcuts for you.
1083 1084 \layout Subsection
1084 1085
1085 1086
1086 1087 \begin_inset LatexCommand \label{sec:upgrade}
1087 1088
1088 1089 \end_inset
1089 1090
1090 1091 Upgrading from a previous version
1091 1092 \layout Standard
1092 1093
1093 1094 If you are upgrading from a previous version of IPython, after doing the
1094 1095 routine installation described above, you should call IPython with the
1095 1096
1096 1097 \family typewriter
1097 1098 -upgrade
1098 1099 \family default
1099 1100 option the first time you run your new copy.
1100 1101 This will automatically update your configuration directory while preserving
1101 1102 copies of your old files.
1102 1103 You can then later merge back any personal customizations you may have
1103 1104 made into the new files.
1104 1105 It is a good idea to do this as there may be new options available in the
1105 1106 new configuration files which you will not have.
1106 1107 \layout Standard
1107 1108
1108 1109 Under Windows, if you don't know how to call python scripts with arguments
1109 1110 from a command line, simply delete the old config directory and IPython
1110 1111 will make a new one.
1111 1112 Win2k and WinXP users will find it in
1112 1113 \family typewriter
1113 1114 C:
1114 1115 \backslash
1115 1116 Documents and Settings
1116 1117 \backslash
1117 1118 YourUserName
1118 1119 \backslash
1119 1120 .ipython
1120 1121 \family default
1121 1122 , and Win 9x users under
1122 1123 \family typewriter
1123 1124 C:
1124 1125 \backslash
1125 1126 Program Files
1126 1127 \backslash
1127 1128 IPython
1128 1129 \backslash
1129 1130 .ipython.
1130 1131 \layout Section
1131 1132
1132 1133
1133 1134 \begin_inset LatexCommand \label{sec:good_config}
1134 1135
1135 1136 \end_inset
1136 1137
1137 1138
1138 1139 \begin_inset OptArg
1139 1140 collapsed true
1140 1141
1141 1142 \layout Standard
1142 1143
1143 1144 Initial configuration
1144 1145 \begin_inset ERT
1145 1146 status Collapsed
1146 1147
1147 1148 \layout Standard
1148 1149
1149 1150 \backslash
1150 1151 ldots
1151 1152 \end_inset
1152 1153
1153 1154
1154 1155 \end_inset
1155 1156
1156 1157 Initial configuration of your environment
1157 1158 \layout Standard
1158 1159
1159 1160 This section will help you set various things in your environment for your
1160 1161 IPython sessions to be as efficient as possible.
1161 1162 All of IPython's configuration information, along with several example
1162 1163 files, is stored in a directory named by default
1163 1164 \family typewriter
1164 1165 $HOME/.ipython
1165 1166 \family default
1166 1167 .
1167 1168 You can change this by defining the environment variable
1168 1169 \family typewriter
1169 1170 IPYTHONDIR
1170 1171 \family default
1171 1172 , or at runtime with the command line option
1172 1173 \family typewriter
1173 1174 -ipythondir
1174 1175 \family default
1175 1176 .
1176 1177 \layout Standard
1177 1178
1178 1179 If all goes well, the first time you run IPython it should automatically
1179 1180 create a user copy of the config directory for you, based on its builtin
1180 1181 defaults.
1181 1182 You can look at the files it creates to learn more about configuring the
1182 1183 system.
1183 1184 The main file you will modify to configure IPython's behavior is called
1184 1185
1185 1186 \family typewriter
1186 1187 ipythonrc
1187 1188 \family default
1188 1189 (with a
1189 1190 \family typewriter
1190 1191 .ini
1191 1192 \family default
1192 1193 extension under Windows), included for reference in Sec.
1193 1194
1194 1195 \begin_inset LatexCommand \ref{sec:ipytonrc-sample}
1195 1196
1196 1197 \end_inset
1197 1198
1198 1199 .
1199 1200 This file is very commented and has many variables you can change to suit
1200 1201 your taste, you can find more details in Sec.
1201 1202
1202 1203 \begin_inset LatexCommand \ref{sec:customization}
1203 1204
1204 1205 \end_inset
1205 1206
1206 1207 .
1207 1208 Here we discuss the basic things you will want to make sure things are
1208 1209 working properly from the beginning.
1209 1210 \layout Subsection
1210 1211
1211 1212
1212 1213 \begin_inset LatexCommand \label{sec:help-access}
1213 1214
1214 1215 \end_inset
1215 1216
1216 1217 Access to the Python help system
1217 1218 \layout Standard
1218 1219
1219 1220 This is true for Python in general (not just for IPython): you should have
1220 1221 an environment variable called
1221 1222 \family typewriter
1222 1223 PYTHONDOCS
1223 1224 \family default
1224 1225 pointing to the directory where your HTML Python documentation lives.
1225 1226 In my system it's
1226 1227 \family typewriter
1227 1228 /usr/share/doc/python-docs-2.3.4/html
1228 1229 \family default
1229 1230 , check your local details or ask your systems administrator.
1230 1231
1231 1232 \layout Standard
1232 1233
1233 1234 This is the directory which holds the HTML version of the Python manuals.
1234 1235 Unfortunately it seems that different Linux distributions package these
1235 1236 files differently, so you may have to look around a bit.
1236 1237 Below I show the contents of this directory on my system for reference:
1237 1238 \layout Standard
1238 1239
1239 1240
1240 1241 \family typewriter
1241 1242 [html]> ls
1242 1243 \newline
1243 1244 about.dat acks.html dist/ ext/ index.html lib/ modindex.html stdabout.dat tut/
1244 1245 about.html api/ doc/ icons/ inst/ mac/ ref/ style.css
1245 1246 \layout Standard
1246 1247
1247 1248 You should really make sure this variable is correctly set so that Python's
1248 1249 pydoc-based help system works.
1249 1250 It is a powerful and convenient system with full access to the Python manuals
1250 1251 and all modules accessible to you.
1251 1252 \layout Standard
1252 1253
1253 1254 Under Windows it seems that pydoc finds the documentation automatically,
1254 1255 so no extra setup appears necessary.
1255 1256 \layout Subsection
1256 1257
1257 1258 Editor
1258 1259 \layout Standard
1259 1260
1260 1261 The
1261 1262 \family typewriter
1262 1263 %edit
1263 1264 \family default
1264 1265 command (and its alias
1265 1266 \family typewriter
1266 1267 %ed
1267 1268 \family default
1268 1269 ) will invoke the editor set in your environment as
1269 1270 \family typewriter
1270 1271 EDITOR
1271 1272 \family default
1272 1273 .
1273 1274 If this variable is not set, it will default to
1274 1275 \family typewriter
1275 1276 vi
1276 1277 \family default
1277 1278 under Linux/Unix and to
1278 1279 \family typewriter
1279 1280 notepad
1280 1281 \family default
1281 1282 under Windows.
1282 1283 You may want to set this variable properly and to a lightweight editor
1283 1284 which doesn't take too long to start (that is, something other than a new
1284 1285 instance of
1285 1286 \family typewriter
1286 1287 Emacs
1287 1288 \family default
1288 1289 ).
1289 1290 This way you can edit multi-line code quickly and with the power of a real
1290 1291 editor right inside IPython.
1291 1292
1292 1293 \layout Standard
1293 1294
1294 1295 If you are a dedicated
1295 1296 \family typewriter
1296 1297 Emacs
1297 1298 \family default
1298 1299 user, you should set up the
1299 1300 \family typewriter
1300 1301 Emacs
1301 1302 \family default
1302 1303 server so that new requests are handled by the original process.
1303 1304 This means that almost no time is spent in handling the request (assuming
1304 1305 an
1305 1306 \family typewriter
1306 1307 Emacs
1307 1308 \family default
1308 1309 process is already running).
1309 1310 For this to work, you need to set your
1310 1311 \family typewriter
1311 1312 EDITOR
1312 1313 \family default
1313 1314 environment variable to
1314 1315 \family typewriter
1315 1316 'emacsclient'
1316 1317 \family default
1317 1318 .
1318 1319
1319 1320 \family typewriter
1320 1321
1321 1322 \family default
1322 1323 The code below, supplied by Francois Pinard, can then be used in your
1323 1324 \family typewriter
1324 1325 .emacs
1325 1326 \family default
1326 1327 file to enable the server:
1327 1328 \layout Standard
1328 1329
1329 1330
1330 1331 \family typewriter
1331 1332 (defvar server-buffer-clients)
1332 1333 \newline
1333 1334 (when (and (fboundp 'server-start) (string-equal (getenv "TERM") 'xterm))
1334 1335 \newline
1335 1336
1336 1337 \begin_inset ERT
1337 1338 status Collapsed
1338 1339
1339 1340 \layout Standard
1340 1341
1341 1342 \backslash
1342 1343 hspace*{0mm}
1343 1344 \end_inset
1344 1345
1345 1346 \SpecialChar ~
1346 1347 \SpecialChar ~
1347 1348 (server-start)
1348 1349 \newline
1349 1350
1350 1351 \begin_inset ERT
1351 1352 status Collapsed
1352 1353
1353 1354 \layout Standard
1354 1355
1355 1356 \backslash
1356 1357 hspace*{0mm}
1357 1358 \end_inset
1358 1359
1359 1360 \SpecialChar ~
1360 1361 \SpecialChar ~
1361 1362 (defun fp-kill-server-with-buffer-routine ()
1362 1363 \newline
1363 1364
1364 1365 \begin_inset ERT
1365 1366 status Collapsed
1366 1367
1367 1368 \layout Standard
1368 1369
1369 1370 \backslash
1370 1371 hspace*{0mm}
1371 1372 \end_inset
1372 1373
1373 1374 \SpecialChar ~
1374 1375 \SpecialChar ~
1375 1376 \SpecialChar ~
1376 1377 \SpecialChar ~
1377 1378 (and server-buffer-clients (server-done)))
1378 1379 \newline
1379 1380
1380 1381 \begin_inset ERT
1381 1382 status Collapsed
1382 1383
1383 1384 \layout Standard
1384 1385
1385 1386 \backslash
1386 1387 hspace*{0mm}
1387 1388 \end_inset
1388 1389
1389 1390 \SpecialChar ~
1390 1391 \SpecialChar ~
1391 1392 (add-hook 'kill-buffer-hook 'fp-kill-server-with-buffer-routine))
1392 1393 \layout Standard
1393 1394
1394 1395 You can also set the value of this editor via the commmand-line option '-
1395 1396 \family typewriter
1396 1397 editor'
1397 1398 \family default
1398 1399 or in your
1399 1400 \family typewriter
1400 1401 ipythonrc
1401 1402 \family default
1402 1403 file.
1403 1404 This is useful if you wish to use specifically for IPython an editor different
1404 1405 from your typical default (and for Windows users who tend to use fewer
1405 1406 environment variables).
1406 1407 \layout Subsection
1407 1408
1408 1409 Color
1409 1410 \layout Standard
1410 1411
1411 1412 The default IPython configuration has most bells and whistles turned on
1412 1413 (they're pretty safe).
1413 1414 But there's one that
1414 1415 \emph on
1415 1416 may
1416 1417 \emph default
1417 1418 cause problems on some systems: the use of color on screen for displaying
1418 1419 information.
1419 1420 This is very useful, since IPython can show prompts and exception tracebacks
1420 1421 with various colors, display syntax-highlighted source code, and in general
1421 1422 make it easier to visually parse information.
1422 1423 \layout Standard
1423 1424
1424 1425 The following terminals seem to handle the color sequences fine:
1425 1426 \layout Itemize
1426 1427
1427 1428 Linux main text console, KDE Konsole, Gnome Terminal, E-term, rxvt, xterm.
1428 1429 \layout Itemize
1429 1430
1430 1431 CDE terminal (tested under Solaris).
1431 1432 This one boldfaces light colors.
1432 1433 \layout Itemize
1433 1434
1434 1435 (X)Emacs buffers.
1435 1436 See sec.
1436 1437 \begin_inset LatexCommand \ref{sec:emacs}
1437 1438
1438 1439 \end_inset
1439 1440
1440 1441 for more details on using IPython with (X)Emacs.
1441 1442 \layout Itemize
1442 1443
1443 1444 A Windows (XP/2k) command prompt
1444 1445 \emph on
1445 1446 with Gary Bishop's support extensions
1446 1447 \emph default
1447 1448 .
1448 1449 Gary's extensions are discussed in Sec.\SpecialChar ~
1449 1450
1450 1451 \begin_inset LatexCommand \ref{sub:Under-Windows}
1451 1452
1452 1453 \end_inset
1453 1454
1454 1455 .
1455 1456 \layout Itemize
1456 1457
1457 1458 A Windows (XP/2k) CygWin shell.
1458 1459 Although some users have reported problems; it is not clear whether there
1459 1460 is an issue for everyone or only under specific configurations.
1460 1461 If you have full color support under cygwin, please post to the IPython
1461 1462 mailing list so this issue can be resolved for all users.
1462 1463 \layout Standard
1463 1464
1464 1465 These have shown problems:
1465 1466 \layout Itemize
1466 1467
1467 1468 Windows command prompt in WinXP/2k logged into a Linux machine via telnet
1468 1469 or ssh.
1469 1470 \layout Itemize
1470 1471
1471 1472 Windows native command prompt in WinXP/2k,
1472 1473 \emph on
1473 1474 without
1474 1475 \emph default
1475 1476 Gary Bishop's extensions.
1476 1477 Once Gary's readline library is installed, the normal WinXP/2k command
1477 1478 prompt works perfectly.
1478 1479 \layout Standard
1479 1480
1480 1481 Currently the following color schemes are available:
1481 1482 \layout Itemize
1482 1483
1483 1484
1484 1485 \family typewriter
1485 1486 NoColor
1486 1487 \family default
1487 1488 : uses no color escapes at all (all escapes are empty
1488 1489 \begin_inset Quotes eld
1489 1490 \end_inset
1490 1491
1491 1492
1492 1493 \begin_inset Quotes eld
1493 1494 \end_inset
1494 1495
1495 1496 strings).
1496 1497 This 'scheme' is thus fully safe to use in any terminal.
1497 1498 \layout Itemize
1498 1499
1499 1500
1500 1501 \family typewriter
1501 1502 Linux
1502 1503 \family default
1503 1504 : works well in Linux console type environments: dark background with light
1504 1505 fonts.
1505 1506 It uses bright colors for information, so it is difficult to read if you
1506 1507 have a light colored background.
1507 1508 \layout Itemize
1508 1509
1509 1510
1510 1511 \family typewriter
1511 1512 LightBG
1512 1513 \family default
1513 1514 : the basic colors are similar to those in the
1514 1515 \family typewriter
1515 1516 Linux
1516 1517 \family default
1517 1518 scheme but darker.
1518 1519 It is easy to read in terminals with light backgrounds.
1519 1520 \layout Standard
1520 1521
1521 1522 IPython uses colors for two main groups of things: prompts and tracebacks
1522 1523 which are directly printed to the terminal, and the object introspection
1523 1524 system which passes large sets of data through a pager.
1524 1525 \layout Subsubsection
1525 1526
1526 1527 Input/Output prompts and exception tracebacks
1527 1528 \layout Standard
1528 1529
1529 1530 You can test whether the colored prompts and tracebacks work on your system
1530 1531 interactively by typing
1531 1532 \family typewriter
1532 1533 '%colors Linux'
1533 1534 \family default
1534 1535 at the prompt (use '
1535 1536 \family typewriter
1536 1537 %colors LightBG'
1537 1538 \family default
1538 1539 if your terminal has a light background).
1539 1540 If the input prompt shows garbage like:
1540 1541 \newline
1541 1542
1542 1543 \family typewriter
1543 1544 [0;32mIn [[1;32m1[0;32m]: [0;00m
1544 1545 \family default
1545 1546
1546 1547 \newline
1547 1548 instead of (in color) something like:
1548 1549 \newline
1549 1550
1550 1551 \family typewriter
1551 1552 In [1]:
1552 1553 \family default
1553 1554
1554 1555 \newline
1555 1556 this means that your terminal doesn't properly handle color escape sequences.
1556 1557 You can go to a 'no color' mode by typing '
1557 1558 \family typewriter
1558 1559 %colors NoColor
1559 1560 \family default
1560 1561 '.
1561 1562
1562 1563 \layout Standard
1563 1564
1564 1565 You can try using a different terminal emulator program.
1565 1566 To permanently set your color preferences, edit the file
1566 1567 \family typewriter
1567 1568 $HOME/.ipython/ipythonrc
1568 1569 \family default
1569 1570 and set the
1570 1571 \family typewriter
1571 1572 colors
1572 1573 \family default
1573 1574 option to the desired value.
1574 1575 \layout Subsubsection
1575 1576
1576 1577 Object details (types, docstrings, source code, etc.)
1577 1578 \layout Standard
1578 1579
1579 1580 IPython has a set of special functions for studying the objects you are
1580 1581 working with, discussed in detail in Sec.
1581 1582
1582 1583 \begin_inset LatexCommand \ref{sec:dyn-object-info}
1583 1584
1584 1585 \end_inset
1585 1586
1586 1587 .
1587 1588 But this system relies on passing information which is longer than your
1588 1589 screen through a data pager, such as the common Unix
1589 1590 \family typewriter
1590 1591 less
1591 1592 \family default
1592 1593 and
1593 1594 \family typewriter
1594 1595 more
1595 1596 \family default
1596 1597 programs.
1597 1598 In order to be able to see this information in color, your pager needs
1598 1599 to be properly configured.
1599 1600 I strongly recommend using
1600 1601 \family typewriter
1601 1602 less
1602 1603 \family default
1603 1604 instead of
1604 1605 \family typewriter
1605 1606 more
1606 1607 \family default
1607 1608 , as it seems that
1608 1609 \family typewriter
1609 1610 more
1610 1611 \family default
1611 1612 simply can not understand colored text correctly.
1612 1613 \layout Standard
1613 1614
1614 1615 In order to configure
1615 1616 \family typewriter
1616 1617 less
1617 1618 \family default
1618 1619 as your default pager, do the following:
1619 1620 \layout Enumerate
1620 1621
1621 1622 Set the environment
1622 1623 \family typewriter
1623 1624 PAGER
1624 1625 \family default
1625 1626 variable to
1626 1627 \family typewriter
1627 1628 less
1628 1629 \family default
1629 1630 .
1630 1631 \layout Enumerate
1631 1632
1632 1633 Set the environment
1633 1634 \family typewriter
1634 1635 LESS
1635 1636 \family default
1636 1637 variable to
1637 1638 \family typewriter
1638 1639 -r
1639 1640 \family default
1640 1641 (plus any other options you always want to pass to
1641 1642 \family typewriter
1642 1643 less
1643 1644 \family default
1644 1645 by default).
1645 1646 This tells
1646 1647 \family typewriter
1647 1648 less
1648 1649 \family default
1649 1650 to properly interpret control sequences, which is how color information
1650 1651 is given to your terminal.
1651 1652 \layout Standard
1652 1653
1653 1654 For the
1654 1655 \family typewriter
1655 1656 csh
1656 1657 \family default
1657 1658 or
1658 1659 \family typewriter
1659 1660 tcsh
1660 1661 \family default
1661 1662 shells, add to your
1662 1663 \family typewriter
1663 1664 ~/.cshrc
1664 1665 \family default
1665 1666 file the lines:
1666 1667 \layout Standard
1667 1668
1668 1669
1669 1670 \family typewriter
1670 1671 setenv PAGER less
1671 1672 \newline
1672 1673 setenv LESS -r
1673 1674 \layout Standard
1674 1675
1675 1676 There is similar syntax for other Unix shells, look at your system documentation
1676 1677 for details.
1677 1678 \layout Standard
1678 1679
1679 1680 If you are on a system which lacks proper data pagers (such as Windows),
1680 1681 IPython will use a very limited builtin pager.
1681 1682 \layout Subsection
1682 1683
1683 1684
1684 1685 \begin_inset LatexCommand \label{sec:emacs}
1685 1686
1686 1687 \end_inset
1687 1688
1688 1689 (X)Emacs configuration
1689 1690 \layout Standard
1690 1691
1691 1692 Thanks to the work of Alexander Schmolck and Prabhu Ramachandran, currently
1692 1693 (X)Emacs and IPython get along very well.
1693 1694
1694 1695 \layout Standard
1695 1696
1696 1697
1697 1698 \series bold
1698 1699 Important note:
1699 1700 \series default
1700 1701 You will need to use a recent enough version of
1701 1702 \family typewriter
1702 1703 python-mode.el
1703 1704 \family default
1704 1705 , along with the file
1705 1706 \family typewriter
1706 1707 ipython.el
1707 1708 \family default
1708 1709 .
1709 1710 You can check that the version you have of
1710 1711 \family typewriter
1711 1712 python-mode.el
1712 1713 \family default
1713 1714 is new enough by either looking at the revision number in the file itself,
1714 1715 or asking for it in (X)Emacs via
1715 1716 \family typewriter
1716 1717 M-x py-version
1717 1718 \family default
1718 1719 .
1719 1720 Versions 4.68 and newer contain the necessary fixes for proper IPython support.
1720 1721 \layout Standard
1721 1722
1722 1723 The file
1723 1724 \family typewriter
1724 1725 ipython.el
1725 1726 \family default
1726 1727 is included with the IPython distribution, in the documentation directory
1727 1728 (where this manual resides in PDF and HTML formats).
1728 1729 \layout Standard
1729 1730
1730 1731 Once you put these files in your Emacs path, all you need in your
1731 1732 \family typewriter
1732 1733 .emacs
1733 1734 \family default
1734 1735 file is:
1735 1736 \layout Standard
1736 1737
1737 1738
1738 1739 \family typewriter
1739 1740 (require 'ipython)
1740 1741 \layout Standard
1741 1742
1742 1743 This should give you full support for executing code snippets via IPython,
1743 1744 opening IPython as your Python shell via
1744 1745 \family typewriter
1745 1746 C-c\SpecialChar ~
1746 1747 !
1747 1748 \family default
1748 1749 , etc.
1749 1750
1750 1751 \layout Subsubsection*
1751 1752
1752 1753 Notes
1753 1754 \layout Itemize
1754 1755
1755 1756 There is one caveat you should be aware of: you must start the IPython shell
1756 1757
1757 1758 \emph on
1758 1759 before
1759 1760 \emph default
1760 1761 attempting to execute any code regions via
1761 1762 \family typewriter
1762 1763 C-c\SpecialChar ~
1763 1764 |
1764 1765 \family default
1765 1766 .
1766 1767 Simply type
1767 1768 \family typewriter
1768 1769 C-c\SpecialChar ~
1769 1770 !
1770 1771 \family default
1771 1772 to start IPython before passing any code regions to the interpreter, and
1772 1773 you shouldn't experience any problems.
1773 1774 \newline
1774 1775 This is due to a bug in Python itself, which has been fixed for Python 2.3,
1775 1776 but exists as of Python 2.2.2 (reported as SF bug [ 737947 ]).
1776 1777 \layout Itemize
1777 1778
1778 1779 The (X)Emacs support is maintained by Alexander Schmolck, so all comments/reques
1779 1780 ts should be directed to him through the IPython mailing lists.
1780 1781
1781 1782 \layout Itemize
1782 1783
1783 1784 This code is still somewhat experimental so it's a bit rough around the
1784 1785 edges (although in practice, it works quite well).
1785 1786 \layout Itemize
1786 1787
1787 1788 Be aware that if you customize
1788 1789 \family typewriter
1789 1790 py-python-command
1790 1791 \family default
1791 1792 previously, this value will override what
1792 1793 \family typewriter
1793 1794 ipython.el
1794 1795 \family default
1795 1796 does (because loading the customization variables comes later).
1796 1797 \layout Section
1797 1798
1798 1799
1799 1800 \begin_inset LatexCommand \label{sec:quick_tips}
1800 1801
1801 1802 \end_inset
1802 1803
1803 1804 Quick tips
1804 1805 \layout Standard
1805 1806
1806 1807 IPython can be used as an improved replacement for the Python prompt, and
1807 1808 for that you don't really need to read any more of this manual.
1808 1809 But in this section we'll try to summarize a few tips on how to make the
1809 1810 most effective use of it for everyday Python development, highlighting
1810 1811 things you might miss in the rest of the manual (which is getting long).
1811 1812 We'll give references to parts in the manual which provide more detail
1812 1813 when appropriate.
1813 1814 \layout Standard
1814 1815
1815 1816 The following article by Jeremy Jones provides an introductory tutorial
1816 1817 about IPython:
1817 1818 \newline
1818 1819
1819 1820 \begin_inset LatexCommand \htmlurl{http://www.onlamp.com/pub/a/python/2005/01/27/ipython.html}
1820 1821
1821 1822 \end_inset
1822 1823
1823 1824
1824 1825 \layout Itemize
1825 1826
1826 1827 The TAB key.
1827 1828 TAB-completion, especially for attributes, is a convenient way to explore
1828 1829 the structure of any object you're dealing with.
1829 1830 Simply type
1830 1831 \family typewriter
1831 1832 object_name.<TAB>
1832 1833 \family default
1833 1834 and a list of the object's attributes will be printed (see sec.
1834 1835
1835 1836 \begin_inset LatexCommand \ref{sec:readline}
1836 1837
1837 1838 \end_inset
1838 1839
1839 1840 for more).
1840 1841 Tab completion also works on file and directory names, which combined with
1841 1842 IPython's alias system allows you to do from within IPython many of the
1842 1843 things you normally would need the system shell for.
1843 1844
1844 1845 \layout Itemize
1845 1846
1846 1847 Explore your objects.
1847 1848 Typing
1848 1849 \family typewriter
1849 1850 object_name?
1850 1851 \family default
1851 1852 will print all sorts of details about any object, including docstrings,
1852 1853 function definition lines (for call arguments) and constructor details
1853 1854 for classes.
1854 1855 The magic commands
1855 1856 \family typewriter
1856 1857 %pdoc
1857 1858 \family default
1858 1859 ,
1859 1860 \family typewriter
1860 1861 %pdef
1861 1862 \family default
1862 1863 ,
1863 1864 \family typewriter
1864 1865 %psource
1865 1866 \family default
1866 1867 and
1867 1868 \family typewriter
1868 1869 %pfile
1869 1870 \family default
1870 1871 will respectively print the docstring, function definition line, full source
1871 1872 code and the complete file for any object (when they can be found).
1872 1873 If automagic is on (it is by default), you don't need to type the '
1873 1874 \family typewriter
1874 1875 %
1875 1876 \family default
1876 1877 ' explicitly.
1877 1878 See sec.
1878 1879
1879 1880 \begin_inset LatexCommand \ref{sec:dyn-object-info}
1880 1881
1881 1882 \end_inset
1882 1883
1883 1884 for more.
1884 1885 \layout Itemize
1885 1886
1886 1887 The
1887 1888 \family typewriter
1888 1889 %run
1889 1890 \family default
1890 1891 magic command allows you to run any python script and load all of its data
1891 1892 directly into the interactive namespace.
1892 1893 Since the file is re-read from disk each time, changes you make to it are
1893 1894 reflected immediately (in contrast to the behavior of
1894 1895 \family typewriter
1895 1896 import
1896 1897 \family default
1897 1898 ).
1898 1899 I rarely use
1899 1900 \family typewriter
1900 1901 import
1901 1902 \family default
1902 1903 for code I am testing, relying on
1903 1904 \family typewriter
1904 1905 %run
1905 1906 \family default
1906 1907 instead.
1907 1908 See sec.
1908 1909
1909 1910 \begin_inset LatexCommand \ref{sec:magic}
1910 1911
1911 1912 \end_inset
1912 1913
1913 1914 for more on this and other magic commands, or type the name of any magic
1914 1915 command and ? to get details on it.
1915 1916 See also sec.
1916 1917
1917 1918 \begin_inset LatexCommand \ref{sec:dreload}
1918 1919
1919 1920 \end_inset
1920 1921
1921 1922 for a recursive reload command.
1922 1923 \newline
1923 1924
1924 1925 \family typewriter
1925 1926 %run
1926 1927 \family default
1927 1928 also has special flags for timing the execution of your scripts (
1928 1929 \family typewriter
1929 1930 -t
1930 1931 \family default
1931 1932 ) and for executing them under the control of either Python's
1932 1933 \family typewriter
1933 1934 pdb
1934 1935 \family default
1935 1936 debugger (
1936 1937 \family typewriter
1937 1938 -d
1938 1939 \family default
1939 1940 ) or profiler (
1940 1941 \family typewriter
1941 1942 -p
1942 1943 \family default
1943 1944 ).
1944 1945 With all of these,
1945 1946 \family typewriter
1946 1947 %run
1947 1948 \family default
1948 1949 can be used as the main tool for efficient interactive development of code
1949 1950 which you write in your editor of choice.
1950 1951 \layout Itemize
1951 1952
1952 1953 Use the Python debugger,
1953 1954 \family typewriter
1954 1955 pdb
1955 1956 \family default
1956 1957
1957 1958 \begin_inset Foot
1958 1959 collapsed true
1959 1960
1960 1961 \layout Standard
1961 1962
1962 1963 Thanks to Christian Hart and Matthew Arnison for the suggestions leading
1963 1964 to IPython's improved debugger and profiler support.
1964 1965 \end_inset
1965 1966
1966 1967 .
1967 1968 The
1968 1969 \family typewriter
1969 1970 %pdb
1970 1971 \family default
1971 1972 command allows you to toggle on and off the automatic invocation of the
1972 1973 pdb debugger at any uncaught exception.
1973 1974 The advantage of this is that pdb starts
1974 1975 \emph on
1975 1976 inside
1976 1977 \emph default
1977 1978 the function where the exception occurred, with all data still available.
1978 1979 You can print variables, see code, execute statements and even walk up
1979 1980 and down the call stack to track down the true source of the problem (which
1980 1981 often is many layers in the stack above where the exception gets triggered).
1981 1982 \newline
1982 1983 Running programs with
1983 1984 \family typewriter
1984 1985 %run
1985 1986 \family default
1986 1987 and pdb active can be an efficient to develop and debug code, in many cases
1987 1988 eliminating the need for
1988 1989 \family typewriter
1989 1990 print
1990 1991 \family default
1991 1992 statements or external debugging tools.
1992 1993 I often simply put a
1993 1994 \family typewriter
1994 1995 1/0
1995 1996 \family default
1996 1997 in a place where I want to take a look so that pdb gets called, quickly
1997 1998 view whatever variables I need to or test various pieces of code and then
1998 1999 remove the
1999 2000 \family typewriter
2000 2001 1/0
2001 2002 \family default
2002 2003 .
2003 2004 \newline
2004 2005 Note also that `
2005 2006 \family typewriter
2006 2007 %run -d
2007 2008 \family default
2008 2009 ' activates
2009 2010 \family typewriter
2010 2011 pdb
2011 2012 \family default
2012 2013 and automatically sets initial breakpoints for you to step through your
2013 2014 code, watch variables, etc.
2014 2015 See Sec.\SpecialChar ~
2015 2016
2016 2017 \begin_inset LatexCommand \ref{sec:cache_output}
2017 2018
2018 2019 \end_inset
2019 2020
2020 2021 for details.
2021 2022 \layout Itemize
2022 2023
2023 2024 Use the output cache.
2024 2025 All output results are automatically stored in a global dictionary named
2025 2026
2026 2027 \family typewriter
2027 2028 Out
2028 2029 \family default
2029 2030 and variables named
2030 2031 \family typewriter
2031 2032 _1
2032 2033 \family default
2033 2034 ,
2034 2035 \family typewriter
2035 2036 _2
2036 2037 \family default
2037 2038 , etc.
2038 2039 alias them.
2039 2040 For example, the result of input line 4 is available either as
2040 2041 \family typewriter
2041 2042 Out[4]
2042 2043 \family default
2043 2044 or as
2044 2045 \family typewriter
2045 2046 _4
2046 2047 \family default
2047 2048 .
2048 2049 Additionally, three variables named
2049 2050 \family typewriter
2050 2051 _
2051 2052 \family default
2052 2053 ,
2053 2054 \family typewriter
2054 2055 __
2055 2056 \family default
2056 2057 and
2057 2058 \family typewriter
2058 2059 ___
2059 2060 \family default
2060 2061 are always kept updated with the for the last three results.
2061 2062 This allows you to recall any previous result and further use it for new
2062 2063 calculations.
2063 2064 See Sec.\SpecialChar ~
2064 2065
2065 2066 \begin_inset LatexCommand \ref{sec:cache_output}
2066 2067
2067 2068 \end_inset
2068 2069
2069 2070 for more.
2070 2071 \layout Itemize
2071 2072
2072 2073 Put a '
2073 2074 \family typewriter
2074 2075 ;
2075 2076 \family default
2076 2077 ' at the end of a line to supress the printing of output.
2077 2078 This is useful when doing calculations which generate long output you are
2078 2079 not interested in seeing.
2079 2080 The
2080 2081 \family typewriter
2081 2082 _*
2082 2083 \family default
2083 2084 variables and the
2084 2085 \family typewriter
2085 2086 Out[]
2086 2087 \family default
2087 2088 list do get updated with the contents of the output, even if it is not
2088 2089 printed.
2089 2090 You can thus still access the generated results this way for further processing.
2090 2091 \layout Itemize
2091 2092
2092 2093 A similar system exists for caching input.
2093 2094 All input is stored in a global list called
2094 2095 \family typewriter
2095 2096 In
2096 2097 \family default
2097 2098 , so you can re-execute lines 22 through 28 plus line 34 by typing
2098 2099 \family typewriter
2099 2100 'exec In[22:29]+In[34]'
2100 2101 \family default
2101 2102 (using Python slicing notation).
2102 2103 If you need to execute the same set of lines often, you can assign them
2103 2104 to a macro with the
2104 2105 \family typewriter
2105 2106 %macro
2106 2107 \family default
2107 2108
2108 2109 \family typewriter
2109 2110 function.
2110 2111
2111 2112 \family default
2112 2113 See sec.
2113 2114
2114 2115 \begin_inset LatexCommand \ref{sec:cache_input}
2115 2116
2116 2117 \end_inset
2117 2118
2118 2119 for more.
2119 2120 \layout Itemize
2120 2121
2121 2122 Use your input history.
2122 2123 The
2123 2124 \family typewriter
2124 2125 %hist
2125 2126 \family default
2126 2127 command can show you all previous input, without line numbers if desired
2127 2128 (option
2128 2129 \family typewriter
2129 2130 -n
2130 2131 \family default
2131 2132 ) so you can directly copy and paste code either back in IPython or in a
2132 2133 text editor.
2133 2134 You can also save all your history by turning on logging via
2134 2135 \family typewriter
2135 2136 %logstart
2136 2137 \family default
2137 2138 ; these logs can later be either reloaded as IPython sessions or used as
2138 2139 code for your programs.
2139 2140 \layout Itemize
2140 2141
2141 2142 Define your own macros with
2142 2143 \family typewriter
2143 2144 %macro
2144 2145 \family default
2145 2146 .
2146 2147 This can be useful for automating sequences of expressions when working
2147 2148 interactively.
2148 2149 \layout Itemize
2149 2150
2150 2151 Define your own system aliases.
2151 2152 Even though IPython gives you access to your system shell via the
2152 2153 \family typewriter
2153 2154 !
2154 2155 \family default
2155 2156 prefix, it is convenient to have aliases to the system commands you use
2156 2157 most often.
2157 2158 This allows you to work seamlessly from inside IPython with the same commands
2158 2159 you are used to in your system shell.
2159 2160 \newline
2160 2161 IPython comes with some pre-defined aliases and a complete system for changing
2161 2162 directories, both via a stack (see
2162 2163 \family typewriter
2163 2164 %pushd
2164 2165 \family default
2165 2166 ,
2166 2167 \family typewriter
2167 2168 %popd
2168 2169 \family default
2169 2170 and
2170 2171 \family typewriter
2171 2172 %ds
2172 2173 \family default
2173 2174 ) and via direct
2174 2175 \family typewriter
2175 2176 %cd
2176 2177 \family default
2177 2178 .
2178 2179 The latter keeps a history of visited directories and allows you to go
2179 2180 to any previously visited one.
2180 2181 \layout Itemize
2181 2182
2182 2183 Use Python to manipulate the results of system commands.
2183 2184 The `
2184 2185 \family typewriter
2185 2186 !!
2186 2187 \family default
2187 2188 ' special syntax, and the
2188 2189 \family typewriter
2189 2190 %sc
2190 2191 \family default
2191 2192 and
2192 2193 \family typewriter
2193 2194 %sx
2194 2195 \family default
2195 2196 magic commands allow you to capture system output into Python variables.
2196 2197 \layout Itemize
2197 2198
2198 2199 Expand python variables when calling the shell (either via
2199 2200 \family typewriter
2200 2201 `!'
2201 2202 \family default
2202 2203 and
2203 2204 \family typewriter
2204 2205 `!!'
2205 2206 \family default
2206 2207 or via aliases) by prepending a
2207 2208 \family typewriter
2208 2209 $
2209 2210 \family default
2210 2211 in front of them.
2211 2212 You can also expand complete python expressions.
2212 2213 See sec.\SpecialChar ~
2213 2214
2214 2215 \begin_inset LatexCommand \ref{sub:System-shell-access}
2215 2216
2216 2217 \end_inset
2217 2218
2218 2219 for more.
2219 2220 \layout Itemize
2220 2221
2221 2222 Use profiles to maintain different configurations (modules to load, function
2222 2223 definitions, option settings) for particular tasks.
2223 2224 You can then have customized versions of IPython for specific purposes.
2224 2225 See sec.\SpecialChar ~
2225 2226
2226 2227 \begin_inset LatexCommand \ref{sec:profiles}
2227 2228
2228 2229 \end_inset
2229 2230
2230 2231 for more.
2231 2232 \layout Itemize
2232 2233
2233 2234 Embed IPython in your programs.
2234 2235 A few lines of code are enough to load a complete IPython inside your own
2235 2236 programs, giving you the ability to work with your data interactively after
2236 2237 automatic processing has been completed.
2237 2238 See sec.\SpecialChar ~
2238 2239
2239 2240 \begin_inset LatexCommand \ref{sec:embed}
2240 2241
2241 2242 \end_inset
2242 2243
2243 2244 for more.
2244 2245 \layout Itemize
2245 2246
2246 2247 Use the Python profiler.
2247 2248 When dealing with performance issues, the
2248 2249 \family typewriter
2249 2250 %run
2250 2251 \family default
2251 2252 command with a
2252 2253 \family typewriter
2253 2254 -p
2254 2255 \family default
2255 2256 option allows you to run complete programs under the control of the Python
2256 2257 profiler.
2257 2258 The
2258 2259 \family typewriter
2259 2260 %prun
2260 2261 \family default
2261 2262 command does a similar job for single Python expressions (like function
2262 2263 calls).
2263 2264 \layout Itemize
2264 2265
2265 2266 Use
2266 2267 \family typewriter
2267 2268 %edit
2268 2269 \family default
2269 2270 to have almost multiline editing.
2270 2271 While IPython doesn't support true multiline editing, this command allows
2271 2272 you to call an editor on the spot, and IPython will execute the code you
2272 2273 type in there as if it were typed interactively.
2273 2274 \layout Standard
2274 2275
2275 2276 If you have your own favorite tip on using IPython efficiently for a certain
2276 2277 task (especially things which can't be done in the normal Python interpreter),
2277 2278 don't hesitate to send it!
2278 2279 \layout Section
2279 2280
2280 2281 Command-line use
2281 2282 \layout Standard
2282 2283
2283 2284 You start IPython with the command:
2284 2285 \layout Standard
2285 2286
2286 2287
2287 2288 \family typewriter
2288 2289 $ ipython [options] files
2289 2290 \layout Standard
2290 2291
2291 2292 If invoked with no options, it executes all the files listed in sequence
2292 2293 and drops you into the interpreter while still acknowledging any options
2293 2294 you may have set in your ipythonrc file.
2294 2295 This behavior is different from standard Python, which when called as
2295 2296 \family typewriter
2296 2297 python -i
2297 2298 \family default
2298 2299 will only execute one file and ignore your configuration setup.
2299 2300 \layout Standard
2300 2301
2301 2302 Please note that some of the configuration options are not available at
2302 2303 the command line, simply because they are not practical here.
2303 2304 Look into your ipythonrc configuration file for details on those.
2304 2305 This file typically installed in the
2305 2306 \family typewriter
2306 2307 $HOME/.ipython
2307 2308 \family default
2308 2309 directory.
2309 2310 For Windows users,
2310 2311 \family typewriter
2311 2312 $HOME
2312 2313 \family default
2313 2314 resolves to
2314 2315 \family typewriter
2315 2316 C:
2316 2317 \backslash
2317 2318
2318 2319 \backslash
2319 2320 Documents and Settings
2320 2321 \backslash
2321 2322
2322 2323 \backslash
2323 2324 YourUserName
2324 2325 \family default
2325 2326 in most instances.
2326 2327 In the rest of this text, we will refer to this directory as
2327 2328 \family typewriter
2328 2329 IPYTHONDIR
2329 2330 \family default
2330 2331 .
2331 2332 \layout Subsection
2332 2333
2333 2334
2334 2335 \begin_inset LatexCommand \label{sec:threading-opts}
2335 2336
2336 2337 \end_inset
2337 2338
2338 2339 Special Threading Options
2339 2340 \layout Standard
2340 2341
2341 2342 The following special options are ONLY valid at the beginning of the command
2342 2343 line, and not later.
2343 2344 This is because they control the initial- ization of ipython itself, before
2344 2345 the normal option-handling mechanism is active.
2345 2346 \layout List
2346 2347 \labelwidthstring 00.00.0000
2347 2348
2348 2349
2349 2350 \family typewriter
2350 2351 \series bold
2351 2352 -gthread,\SpecialChar ~
2352 2353 -wthread,\SpecialChar ~
2353 2354 -pylab:
2354 2355 \family default
2355 2356 \series default
2356 2357 Only
2357 2358 \emph on
2358 2359 one
2359 2360 \emph default
2360 2361 of these can be given, and it can only be given as the first option passed
2361 2362 to IPython (it will have no effect in any other position).
2362 2363 They provide threading support for the GTK and WXPython toolkits, and for
2363 2364 the matplotlib library.
2364 2365 \layout List
2365 2366 \labelwidthstring 00.00.0000
2366 2367
2367 2368 \SpecialChar ~
2368 2369 If
2369 2370 \family typewriter
2370 2371 -gthread
2371 2372 \family default
2372 2373 is given, IPython starts running a separate thread for GTK operation, so
2373 2374 that pyGTK-based programs can open and control GUIs without blocking IPython.
2374 2375
2375 2376 \layout List
2376 2377 \labelwidthstring 00.00.0000
2377 2378
2378 2379 \SpecialChar ~
2379 2380 Similarly,
2380 2381 \family typewriter
2381 2382 -wthread
2382 2383 \family default
2383 2384 instantiates IPython with threading support for the WXPython toolkit.
2384 2385 You can control WX application windows from within IPython.
2385 2386 \layout List
2386 2387 \labelwidthstring 00.00.0000
2387 2388
2388 2389 \SpecialChar ~
2389 2390 If
2390 2391 \family typewriter
2391 2392 -pylab
2392 2393 \family default
2393 2394 is given, IPython loads special support for the mat- plotlib library (
2394 2395 \begin_inset LatexCommand \htmlurl{http://matplotlib.sourceforge.net}
2395 2396
2396 2397 \end_inset
2397 2398
2398 2399 ), allowing interactive usage of any of its backends as defined in the user's
2399 2400 .matplotlibrc file.
2400 2401 It automatically activates GTK or WX threading for IPyhton if the choice
2401 2402 of matplotlib backend requires it.
2402 2403 It also modifies the
2403 2404 \family typewriter
2404 2405 %run
2405 2406 \family default
2406 2407 command to correctly execute (without blocking) any matplotlib-based script
2407 2408 which calls
2408 2409 \family typewriter
2409 2410 show()
2410 2411 \family default
2411 2412 at the end.
2412 2413
2413 2414 \layout List
2414 2415 \labelwidthstring 00.00.0000
2415 2416
2416 2417
2417 2418 \family typewriter
2418 2419 \series bold
2419 2420 -tk
2420 2421 \family default
2421 2422 \series default
2422 2423 The
2423 2424 \family typewriter
2424 2425 -g/wthread
2425 2426 \family default
2426 2427 options, and
2427 2428 \family typewriter
2428 2429 -pylab
2429 2430 \family default
2430 2431 (if matplotlib is configured to use WX or GTK), will normally block Tk
2431 2432 graphical interfaces.
2432 2433 This means that when either GTK or WX threading is active, any attempt
2433 2434 to open a Tk GUI will result in a dead window, and pos- sibly cause the
2434 2435 Python interpreter to crash.
2435 2436 An extra option,
2436 2437 \family typewriter
2437 2438 -tk
2438 2439 \family default
2439 2440 , is available to address this issue.
2440 2441 It can
2441 2442 \emph on
2442 2443 only
2443 2444 \emph default
2444 2445 be given as a
2445 2446 \emph on
2446 2447 second
2447 2448 \emph default
2448 2449 option after any of the above (
2449 2450 \family typewriter
2450 2451 -gthread
2451 2452 \family default
2452 2453 ,
2453 2454 \family typewriter
2454 2455 -wthread
2455 2456 \family default
2456 2457 or
2457 2458 \family typewriter
2458 2459 -pylab
2459 2460 \family default
2460 2461 ).
2461 2462 \layout List
2462 2463 \labelwidthstring 00.00.0000
2463 2464
2464 2465 \SpecialChar ~
2465 2466 If
2466 2467 \family typewriter
2467 2468 -tk
2468 2469 \family default
2469 2470 is given, IPython will try to coordinate Tk threading with WX or GTK.
2470 2471 This is however potentially unreliable, and you will have to test on your
2471 2472 platform and Python configuration to determine whether it works for you.
2472 2473 Debian users have reported success, apparently due to the fact that Debian
2473 2474 builds all of Tcl, Tk, Tkinter and Python with pthreads support.
2474 2475 Under other Linux environments (such as Fedora Core 2), this option has
2475 2476 caused random crashes and lockups of the Python interpreter.
2476 2477 Under other operating systems (Mac OSX and Windows), you'll need to try
2477 2478 it to find out, since currently no user reports are available.
2478 2479 \layout List
2479 2480 \labelwidthstring 00.00.0000
2480 2481
2481 2482 \SpecialChar ~
2482 2483 There is unfortunately no way for IPython to determine at run time whether
2483 2484
2484 2485 \family typewriter
2485 2486 -tk
2486 2487 \family default
2487 2488 will work reliably or not, so you will need to do some experiments before
2488 2489 relying on it for regular work.
2489 2490
2490 2491 \layout Subsection
2491 2492
2492 2493
2493 2494 \begin_inset LatexCommand \label{sec:cmd-line-opts}
2494 2495
2495 2496 \end_inset
2496 2497
2497 2498 Regular Options
2498 2499 \layout Standard
2499 2500
2500 2501 After the above threading options have been given, regular options can follow
2501 2502 in any order.
2502 2503 All options can be abbreviated to their shortest non-ambiguous form and
2503 2504 are case-sensitive.
2504 2505 One or two dashes can be used.
2505 2506 Some options have an alternate short form, indicated after a
2506 2507 \family typewriter
2507 2508 |
2508 2509 \family default
2509 2510 .
2510 2511 \layout Standard
2511 2512
2512 2513 Most options can also be set from your ipythonrc configuration file.
2513 2514 See the provided example for more details on what the options do.
2514 2515 Options given at the command line override the values set in the ipythonrc
2515 2516 file.
2516 2517 \layout Standard
2517 2518
2518 2519 All options with a
2519 2520 \family typewriter
2520 2521 no|
2521 2522 \family default
2522 2523 prepended can be specified in 'no' form (
2523 2524 \family typewriter
2524 2525 -nooption
2525 2526 \family default
2526 2527 instead of
2527 2528 \family typewriter
2528 2529 -option
2529 2530 \family default
2530 2531 ) to turn the feature off.
2531 2532 \layout List
2532 2533 \labelwidthstring 00.00.0000
2533 2534
2534 2535
2535 2536 \family typewriter
2536 2537 \series bold
2537 2538 -help
2538 2539 \family default
2539 2540 \series default
2540 2541 : print a help message and exit.
2541 2542 \layout List
2542 2543 \labelwidthstring 00.00.0000
2543 2544
2544 2545
2545 2546 \family typewriter
2546 2547 \series bold
2547 2548 -pylab:
2548 2549 \family default
2549 2550 \series default
2550 2551 this can
2551 2552 \emph on
2552 2553 only
2553 2554 \emph default
2554 2555 be given as the
2555 2556 \emph on
2556 2557 first
2557 2558 \emph default
2558 2559 option passed to IPython (it will have no effect in any other position).
2559 2560 It adds special support for the matplotlib library (
2560 2561 \begin_inset LatexCommand \htmlurl[http://matplotlib.sourceforge.net]{http://matplotlib.sourceforge.net}
2561 2562
2562 2563 \end_inset
2563 2564
2564 2565 ), allowing interactive usage of any of its backends as defined in the user's
2565 2566
2566 2567 \family typewriter
2567 2568 .matplotlibrc
2568 2569 \family default
2569 2570 file.
2570 2571 It automatically activates GTK or WX threading for IPyhton if the choice
2571 2572 of matplotlib backend requires it.
2572 2573 It also modifies the
2573 2574 \family typewriter
2574 2575 %run
2575 2576 \family default
2576 2577 command to correctly execute (without blocking) any matplotlib-based script
2577 2578 which calls
2578 2579 \family typewriter
2579 2580 show()
2580 2581 \family default
2581 2582 at the end.
2582 2583 See Sec.\SpecialChar ~
2583 2584
2584 2585 \begin_inset LatexCommand \ref{sec:matplotlib-support}
2585 2586
2586 2587 \end_inset
2587 2588
2588 2589 for more details.
2589 2590 \layout List
2590 2591 \labelwidthstring 00.00.0000
2591 2592
2592 2593
2593 2594 \family typewriter
2594 2595 \series bold
2595 2596 -no|automagic
2596 2597 \series default
2597 2598 :
2598 2599 \family default
2599 2600 make magic commands automatic (without needing their first character to
2600 2601 be
2601 2602 \family typewriter
2602 2603 %
2603 2604 \family default
2604 2605 ).
2605 2606 Type
2606 2607 \family typewriter
2607 2608 %magic
2608 2609 \family default
2609 2610 at the IPython prompt for more information.
2610 2611 \layout List
2611 2612 \labelwidthstring 00.00.0000
2612 2613
2613 2614
2614 2615 \family typewriter
2615 2616 \series bold
2616 2617 -no|banner
2617 2618 \series default
2618 2619 :
2619 2620 \family default
2620 2621 Print the initial information banner (default on).
2621 2622 \layout List
2622 2623 \labelwidthstring 00.00.0000
2623 2624
2624 2625
2625 2626 \family typewriter
2626 2627 \series bold
2627 2628 -c\SpecialChar ~
2628 2629 <command>:
2629 2630 \family default
2630 2631 \series default
2631 2632 execute the given command string, and set sys.argv to
2632 2633 \family typewriter
2633 2634 ['c']
2634 2635 \family default
2635 2636 .
2636 2637 This is similar to the
2637 2638 \family typewriter
2638 2639 -c
2639 2640 \family default
2640 2641 option in the normal Python interpreter.
2641 2642
2642 2643 \layout List
2643 2644 \labelwidthstring 00.00.0000
2644 2645
2645 2646
2646 2647 \family typewriter
2647 2648 \series bold
2648 2649 -cache_size|cs\SpecialChar ~
2649 2650 <n>
2650 2651 \series default
2651 2652 :
2652 2653 \family default
2653 2654 size of the output cache (maximum number of entries to hold in memory).
2654 2655 The default is 1000, you can change it permanently in your config file.
2655 2656 Setting it to 0 completely disables the caching system, and the minimum
2656 2657 value accepted is 20 (if you provide a value less than 20, it is reset
2657 2658 to 0 and a warning is issued) This limit is defined because otherwise you'll
2658 2659 spend more time re-flushing a too small cache than working.
2659 2660 \layout List
2660 2661 \labelwidthstring 00.00.0000
2661 2662
2662 2663
2663 2664 \family typewriter
2664 2665 \series bold
2665 2666 -classic|cl
2666 2667 \series default
2667 2668 :
2668 2669 \family default
2669 2670 Gives IPython a similar feel to the classic Python prompt.
2670 2671 \layout List
2671 2672 \labelwidthstring 00.00.0000
2672 2673
2673 2674
2674 2675 \family typewriter
2675 2676 \series bold
2676 2677 -colors\SpecialChar ~
2677 2678 <scheme>:
2678 2679 \family default
2679 2680 \series default
2680 2681 Color scheme for prompts and exception reporting.
2681 2682 Currently implemented: NoColor, Linux and LightBG.
2682 2683 \layout List
2683 2684 \labelwidthstring 00.00.0000
2684 2685
2685 2686
2686 2687 \family typewriter
2687 2688 \series bold
2688 2689 -no|color_info:
2689 2690 \family default
2690 2691 \series default
2691 2692 IPython can display information about objects via a set of functions, and
2692 2693 optionally can use colors for this, syntax highlighting source code and
2693 2694 various other elements.
2694 2695 However, because this information is passed through a pager (like 'less')
2695 2696 and many pagers get confused with color codes, this option is off by default.
2696 2697 You can test it and turn it on permanently in your ipythonrc file if it
2697 2698 works for you.
2698 2699 As a reference, the 'less' pager supplied with Mandrake 8.2 works ok, but
2699 2700 that in RedHat 7.2 doesn't.
2700 2701 \layout List
2701 2702 \labelwidthstring 00.00.0000
2702 2703
2703 2704 \SpecialChar ~
2704 2705 Test it and turn it on permanently if it works with your system.
2705 2706 The magic function
2706 2707 \family typewriter
2707 2708 %color_info
2708 2709 \family default
2709 2710 allows you to toggle this interactively for testing.
2710 2711 \layout List
2711 2712 \labelwidthstring 00.00.0000
2712 2713
2713 2714
2714 2715 \family typewriter
2715 2716 \series bold
2716 2717 -no|debug
2717 2718 \family default
2718 2719 \series default
2719 2720 : Show information about the loading process.
2720 2721 Very useful to pin down problems with your configuration files or to get
2721 2722 details about session restores.
2722 2723 \layout List
2723 2724 \labelwidthstring 00.00.0000
2724 2725
2725 2726
2726 2727 \family typewriter
2727 2728 \series bold
2728 2729 -no|deep_reload
2729 2730 \series default
2730 2731 :
2731 2732 \family default
2732 2733 IPython can use the
2733 2734 \family typewriter
2734 2735 deep_reload
2735 2736 \family default
2736 2737 module which reloads changes in modules recursively (it replaces the
2737 2738 \family typewriter
2738 2739 reload()
2739 2740 \family default
2740 2741 function, so you don't need to change anything to use it).
2741 2742
2742 2743 \family typewriter
2743 2744 deep_reload()
2744 2745 \family default
2745 2746 forces a full reload of modules whose code may have changed, which the
2746 2747 default
2747 2748 \family typewriter
2748 2749 reload()
2749 2750 \family default
2750 2751 function does not.
2751 2752 \layout List
2752 2753 \labelwidthstring 00.00.0000
2753 2754
2754 2755 \SpecialChar ~
2755 2756 When deep_reload is off, IPython will use the normal
2756 2757 \family typewriter
2757 2758 reload()
2758 2759 \family default
2759 2760 , but deep_reload will still be available as
2760 2761 \family typewriter
2761 2762 dreload()
2762 2763 \family default
2763 2764 .
2764 2765 This feature is off by default [which means that you have both normal
2765 2766 \family typewriter
2766 2767 reload()
2767 2768 \family default
2768 2769 and
2769 2770 \family typewriter
2770 2771 dreload()
2771 2772 \family default
2772 2773 ].
2773 2774 \layout List
2774 2775 \labelwidthstring 00.00.0000
2775 2776
2776 2777
2777 2778 \family typewriter
2778 2779 \series bold
2779 2780 -editor\SpecialChar ~
2780 2781 <name>
2781 2782 \family default
2782 2783 \series default
2783 2784 : Which editor to use with the
2784 2785 \family typewriter
2785 2786 %edit
2786 2787 \family default
2787 2788 command.
2788 2789 By default, IPython will honor your
2789 2790 \family typewriter
2790 2791 EDITOR
2791 2792 \family default
2792 2793 environment variable (if not set, vi is the Unix default and notepad the
2793 2794 Windows one).
2794 2795 Since this editor is invoked on the fly by IPython and is meant for editing
2795 2796 small code snippets, you may want to use a small, lightweight editor here
2796 2797 (in case your default
2797 2798 \family typewriter
2798 2799 EDITOR
2799 2800 \family default
2800 2801 is something like Emacs).
2801 2802 \layout List
2802 2803 \labelwidthstring 00.00.0000
2803 2804
2804 2805
2805 2806 \family typewriter
2806 2807 \series bold
2807 2808 -ipythondir\SpecialChar ~
2808 2809 <name>
2809 2810 \series default
2810 2811 :
2811 2812 \family default
2812 2813 name of your IPython configuration directory
2813 2814 \family typewriter
2814 2815 IPYTHONDIR
2815 2816 \family default
2816 2817 .
2817 2818 This can also be specified through the environment variable
2818 2819 \family typewriter
2819 2820 IPYTHONDIR
2820 2821 \family default
2821 2822 .
2822 2823 \layout List
2823 2824 \labelwidthstring 00.00.0000
2824 2825
2825 2826
2826 2827 \family typewriter
2827 2828 \series bold
2828 2829 -log|l
2829 2830 \family default
2830 2831 \series default
2831 2832 : generate a log file of all input.
2832 2833 Defaults to
2833 2834 \family typewriter
2834 2835 $IPYTHONDIR/log
2835 2836 \family default
2836 2837 .
2837 2838 You can use this to later restore a session by loading your logfile as
2838 2839 a file to be executed with option
2839 2840 \family typewriter
2840 2841 -logplay
2841 2842 \family default
2842 2843 (see below).
2843 2844 \layout List
2844 2845 \labelwidthstring 00.00.0000
2845 2846
2846 2847
2847 2848 \family typewriter
2848 2849 \series bold
2849 2850 -logfile|lf\SpecialChar ~
2850 2851 <name>
2851 2852 \series default
2852 2853 :
2853 2854 \family default
2854 2855 specify the name of your logfile.
2855 2856 \layout List
2856 2857 \labelwidthstring 00.00.0000
2857 2858
2858 2859
2859 2860 \family typewriter
2860 2861 \series bold
2861 2862 -logplay|lp\SpecialChar ~
2862 2863 <name>
2863 2864 \series default
2864 2865 :
2865 2866 \family default
2866 2867 you can replay a previous log.
2867 2868 For restoring a session as close as possible to the state you left it in,
2868 2869 use this option (don't just run the logfile).
2869 2870 With
2870 2871 \family typewriter
2871 2872 -logplay
2872 2873 \family default
2873 2874 , IPython will try to reconstruct the previous working environment in full,
2874 2875 not just execute the commands in the logfile.
2875 2876 \layout List
2876 2877 \labelwidthstring 00.00.0000
2877 2878
2878 2879 \SpecialChar ~
2879 2880 When a session is restored, logging is automatically turned on again with
2880 2881 the name of the logfile it was invoked with (it is read from the log header).
2881 2882 So once you've turned logging on for a session, you can quit IPython and
2882 2883 reload it as many times as you want and it will continue to log its history
2883 2884 and restore from the beginning every time.
2884 2885 \layout List
2885 2886 \labelwidthstring 00.00.0000
2886 2887
2887 2888 \SpecialChar ~
2888 2889 Caveats: there are limitations in this option.
2889 2890 The history variables
2890 2891 \family typewriter
2891 2892 _i*
2892 2893 \family default
2893 2894 ,
2894 2895 \family typewriter
2895 2896 _*
2896 2897 \family default
2897 2898 and
2898 2899 \family typewriter
2899 2900 _dh
2900 2901 \family default
2901 2902 don't get restored properly.
2902 2903 In the future we will try to implement full session saving by writing and
2903 2904 retrieving a 'snapshot' of the memory state of IPython.
2904 2905 But our first attempts failed because of inherent limitations of Python's
2905 2906 Pickle module, so this may have to wait.
2906 2907 \layout List
2907 2908 \labelwidthstring 00.00.0000
2908 2909
2909 2910
2910 2911 \family typewriter
2911 2912 \series bold
2912 2913 -no|messages
2913 2914 \series default
2914 2915 :
2915 2916 \family default
2916 2917 Print messages which IPython collects about its startup process (default
2917 2918 on).
2918 2919 \layout List
2919 2920 \labelwidthstring 00.00.0000
2920 2921
2921 2922
2922 2923 \family typewriter
2923 2924 \series bold
2924 2925 -no|pdb
2925 2926 \family default
2926 2927 \series default
2927 2928 : Automatically call the pdb debugger after every uncaught exception.
2928 2929 If you are used to debugging using pdb, this puts you automatically inside
2929 2930 of it after any call (either in IPython or in code called by it) which
2930 2931 triggers an exception which goes uncaught.
2931 2932 \layout List
2932 2933 \labelwidthstring 00.00.0000
2933 2934
2934 2935
2935 2936 \family typewriter
2936 2937 \series bold
2937 2938 -no|pprint
2938 2939 \series default
2939 2940 :
2940 2941 \family default
2941 2942 ipython can optionally use the pprint (pretty printer) module for displaying
2942 2943 results.
2943 2944 pprint tends to give a nicer display of nested data structures.
2944 2945 If you like it, you can turn it on permanently in your config file (default
2945 2946 off).
2946 2947 \layout List
2947 2948 \labelwidthstring 00.00.0000
2948 2949
2949 2950
2950 2951 \family typewriter
2951 2952 \series bold
2952 2953 -profile|p <name>
2953 2954 \series default
2954 2955 :
2955 2956 \family default
2956 2957 assume that your config file is
2957 2958 \family typewriter
2958 2959 ipythonrc-<name>
2959 2960 \family default
2960 2961 (looks in current dir first, then in
2961 2962 \family typewriter
2962 2963 IPYTHONDIR
2963 2964 \family default
2964 2965 ).
2965 2966 This is a quick way to keep and load multiple config files for different
2966 2967 tasks, especially if you use the include option of config files.
2967 2968 You can keep a basic
2968 2969 \family typewriter
2969 2970 IPYTHONDIR/ipythonrc
2970 2971 \family default
2971 2972 file and then have other 'profiles' which include this one and load extra
2972 2973 things for particular tasks.
2973 2974 For example:
2974 2975 \layout List
2975 2976 \labelwidthstring 00.00.0000
2976 2977
2977 2978
2978 2979 \family typewriter
2979 2980 \SpecialChar ~
2980 2981
2981 2982 \family default
2982 2983 1.
2983 2984
2984 2985 \family typewriter
2985 2986 $HOME/.ipython/ipythonrc
2986 2987 \family default
2987 2988 : load basic things you always want.
2988 2989 \layout List
2989 2990 \labelwidthstring 00.00.0000
2990 2991
2991 2992
2992 2993 \family typewriter
2993 2994 \SpecialChar ~
2994 2995
2995 2996 \family default
2996 2997 2.
2997 2998
2998 2999 \family typewriter
2999 3000 $HOME/.ipython/ipythonrc-math
3000 3001 \family default
3001 3002 : load (1) and basic math-related modules.
3002 3003
3003 3004 \layout List
3004 3005 \labelwidthstring 00.00.0000
3005 3006
3006 3007
3007 3008 \family typewriter
3008 3009 \SpecialChar ~
3009 3010
3010 3011 \family default
3011 3012 3.
3012 3013
3013 3014 \family typewriter
3014 3015 $HOME/.ipython/ipythonrc-numeric
3015 3016 \family default
3016 3017 : load (1) and Numeric and plotting modules.
3017 3018 \layout List
3018 3019 \labelwidthstring 00.00.0000
3019 3020
3020 3021 \SpecialChar ~
3021 3022 Since it is possible to create an endless loop by having circular file
3022 3023 inclusions, IPython will stop if it reaches 15 recursive inclusions.
3023 3024 \layout List
3024 3025 \labelwidthstring 00.00.0000
3025 3026
3026 3027
3027 3028 \family typewriter
3028 3029 \series bold
3029 3030 -prompt_in1|pi1\SpecialChar ~
3030 3031 <string>:
3031 3032 \family default
3032 3033 \series default
3033 3034 Specify the string used for input prompts.
3034 3035 Note that if you are using numbered prompts, the number is represented
3035 3036 with a '
3036 3037 \backslash
3037 3038 #' in the string.
3038 3039 Don't forget to quote strings with spaces embedded in them.
3039 3040 Default: '
3040 3041 \family typewriter
3041 3042 In\SpecialChar ~
3042 3043 [
3043 3044 \backslash
3044 3045 #]:
3045 3046 \family default
3046 3047 '.
3047 3048 Sec.\SpecialChar ~
3048 3049
3049 3050 \begin_inset LatexCommand \ref{sec:prompts}
3050 3051
3051 3052 \end_inset
3052 3053
3053 3054 discusses in detail all the available escapes to customize your prompts.
3054 3055 \layout List
3055 3056 \labelwidthstring 00.00.0000
3056 3057
3057 3058
3058 3059 \family typewriter
3059 3060 \series bold
3060 3061 -prompt_in2|pi2\SpecialChar ~
3061 3062 <string>:
3062 3063 \family default
3063 3064 \series default
3064 3065 Similar to the previous option, but used for the continuation prompts.
3065 3066 The special sequence '
3066 3067 \family typewriter
3067 3068
3068 3069 \backslash
3069 3070 D
3070 3071 \family default
3071 3072 ' is similar to '
3072 3073 \family typewriter
3073 3074
3074 3075 \backslash
3075 3076 #
3076 3077 \family default
3077 3078 ', but with all digits replaced dots (so you can have your continuation
3078 3079 prompt aligned with your input prompt).
3079 3080 Default: '
3080 3081 \family typewriter
3081 3082 \SpecialChar ~
3082 3083 \SpecialChar ~
3083 3084 \SpecialChar ~
3084 3085 .
3085 3086 \backslash
3086 3087 D.:
3087 3088 \family default
3088 3089 ' (note three spaces at the start for alignment with '
3089 3090 \family typewriter
3090 3091 In\SpecialChar ~
3091 3092 [
3092 3093 \backslash
3093 3094 #]
3094 3095 \family default
3095 3096 ').
3096 3097 \layout List
3097 3098 \labelwidthstring 00.00.0000
3098 3099
3099 3100
3100 3101 \family typewriter
3101 3102 \series bold
3102 3103 -prompt_out|po\SpecialChar ~
3103 3104 <string>:
3104 3105 \family default
3105 3106 \series default
3106 3107 String used for output prompts, also uses numbers like
3107 3108 \family typewriter
3108 3109 prompt_in1
3109 3110 \family default
3110 3111 .
3111 3112 Default: '
3112 3113 \family typewriter
3113 3114 Out[
3114 3115 \backslash
3115 3116 #]:
3116 3117 \family default
3117 3118 '
3118 3119 \layout List
3119 3120 \labelwidthstring 00.00.0000
3120 3121
3121 3122
3122 3123 \family typewriter
3123 3124 \series bold
3124 3125 -quick
3125 3126 \family default
3126 3127 \series default
3127 3128 : start in bare bones mode (no config file loaded).
3128 3129 \layout List
3129 3130 \labelwidthstring 00.00.0000
3130 3131
3131 3132
3132 3133 \family typewriter
3133 3134 \series bold
3134 3135 -rcfile\SpecialChar ~
3135 3136 <name>
3136 3137 \series default
3137 3138 :
3138 3139 \family default
3139 3140 name of your IPython resource configuration file.
3140 3141 Normally IPython loads ipythonrc (from current directory) or
3141 3142 \family typewriter
3142 3143 IPYTHONDIR/ipythonrc
3143 3144 \family default
3144 3145 .
3145 3146 \layout List
3146 3147 \labelwidthstring 00.00.0000
3147 3148
3148 3149 \SpecialChar ~
3149 3150 If the loading of your config file fails, IPython starts with a bare bones
3150 3151 configuration (no modules loaded at all).
3151 3152 \layout List
3152 3153 \labelwidthstring 00.00.0000
3153 3154
3154 3155
3155 3156 \family typewriter
3156 3157 \series bold
3157 3158 -no|readline
3158 3159 \family default
3159 3160 \series default
3160 3161 : use the readline library, which is needed to support name completion and
3161 3162 command history, among other things.
3162 3163 It is enabled by default, but may cause problems for users of X/Emacs in
3163 3164 Python comint or shell buffers.
3164 3165 \layout List
3165 3166 \labelwidthstring 00.00.0000
3166 3167
3167 3168 \SpecialChar ~
3168 3169 Note that X/Emacs 'eterm' buffers (opened with
3169 3170 \family typewriter
3170 3171 M-x\SpecialChar ~
3171 3172 term
3172 3173 \family default
3173 3174 ) support IPython's readline and syntax coloring fine, only 'emacs' (
3174 3175 \family typewriter
3175 3176 M-x\SpecialChar ~
3176 3177 shell
3177 3178 \family default
3178 3179 and
3179 3180 \family typewriter
3180 3181 C-c\SpecialChar ~
3181 3182 !
3182 3183 \family default
3183 3184 ) buffers do not.
3184 3185 \layout List
3185 3186 \labelwidthstring 00.00.0000
3186 3187
3187 3188
3188 3189 \family typewriter
3189 3190 \series bold
3190 3191 -screen_length|sl\SpecialChar ~
3191 3192 <n>
3192 3193 \series default
3193 3194 :
3194 3195 \family default
3195 3196 number of lines of your screen.
3196 3197 This is used to control printing of very long strings.
3197 3198 Strings longer than this number of lines will be sent through a pager instead
3198 3199 of directly printed.
3199 3200 \layout List
3200 3201 \labelwidthstring 00.00.0000
3201 3202
3202 3203 \SpecialChar ~
3203 3204 The default value for this is 0, which means IPython will auto-detect your
3204 3205 screen size every time it needs to print certain potentially long strings
3205 3206 (this doesn't change the behavior of the 'print' keyword, it's only triggered
3206 3207 internally).
3207 3208 If for some reason this isn't working well (it needs curses support), specify
3208 3209 it yourself.
3209 3210 Otherwise don't change the default.
3210 3211 \layout List
3211 3212 \labelwidthstring 00.00.0000
3212 3213
3213 3214
3214 3215 \family typewriter
3215 3216 \series bold
3216 3217 -separate_in|si\SpecialChar ~
3217 3218 <string>
3218 3219 \series default
3219 3220 :
3220 3221 \family default
3221 3222 separator before input prompts.
3222 3223 Default: '
3223 3224 \family typewriter
3224 3225
3225 3226 \backslash
3226 3227 n
3227 3228 \family default
3228 3229 '
3229 3230 \layout List
3230 3231 \labelwidthstring 00.00.0000
3231 3232
3232 3233
3233 3234 \family typewriter
3234 3235 \series bold
3235 3236 -separate_out|so\SpecialChar ~
3236 3237 <string>
3237 3238 \family default
3238 3239 \series default
3239 3240 : separator before output prompts.
3240 3241 Default: nothing.
3241 3242 \layout List
3242 3243 \labelwidthstring 00.00.0000
3243 3244
3244 3245
3245 3246 \family typewriter
3246 3247 \series bold
3247 3248 -separate_out2|so2\SpecialChar ~
3248 3249 <string>
3249 3250 \series default
3250 3251 :
3251 3252 \family default
3252 3253 separator after output prompts.
3253 3254 Default: nothing.
3254 3255 \layout List
3255 3256 \labelwidthstring 00.00.0000
3256 3257
3257 3258 \SpecialChar ~
3258 3259 For these three options, use the value 0 to specify no separator.
3259 3260 \layout List
3260 3261 \labelwidthstring 00.00.0000
3261 3262
3262 3263
3263 3264 \family typewriter
3264 3265 \series bold
3265 3266 -nosep
3266 3267 \series default
3267 3268 :
3268 3269 \family default
3269 3270 shorthand for
3270 3271 \family typewriter
3271 3272 '-SeparateIn 0 -SeparateOut 0 -SeparateOut2 0'
3272 3273 \family default
3273 3274 .
3274 3275 Simply removes all input/output separators.
3275 3276 \layout List
3276 3277 \labelwidthstring 00.00.0000
3277 3278
3278 3279
3279 3280 \family typewriter
3280 3281 \series bold
3281 3282 -upgrade
3282 3283 \family default
3283 3284 \series default
3284 3285 : allows you to upgrade your
3285 3286 \family typewriter
3286 3287 IPYTHONDIR
3287 3288 \family default
3288 3289 configuration when you install a new version of IPython.
3289 3290 Since new versions may include new command line options or example files,
3290 3291 this copies updated ipythonrc-type files.
3291 3292 However, it backs up (with a
3292 3293 \family typewriter
3293 3294 .old
3294 3295 \family default
3295 3296 extension) all files which it overwrites so that you can merge back any
3296 3297 customizations you might have in your personal files.
3297 3298 \layout List
3298 3299 \labelwidthstring 00.00.0000
3299 3300
3300 3301
3301 3302 \family typewriter
3302 3303 \series bold
3303 3304 -Version
3304 3305 \series default
3305 3306 :
3306 3307 \family default
3307 3308 print version information and exit.
3308 3309 \layout List
3309 3310 \labelwidthstring 00.00.0000
3310 3311
3311 3312
3312 3313 \family typewriter
3313 3314 \series bold
3314 3315 -xmode <modename>
3315 3316 \series default
3316 3317 :
3317 3318 \family default
3318 3319 Mode for exception reporting.
3319 3320 \layout List
3320 3321 \labelwidthstring 00.00.0000
3321 3322
3322 3323 \SpecialChar ~
3323 3324 Valid modes: Plain, Context and Verbose.
3324 3325 \layout List
3325 3326 \labelwidthstring 00.00.0000
3326 3327
3327 3328 \SpecialChar ~
3328 3329 Plain: similar to python's normal traceback printing.
3329 3330 \layout List
3330 3331 \labelwidthstring 00.00.0000
3331 3332
3332 3333 \SpecialChar ~
3333 3334 Context: prints 5 lines of context source code around each line in the
3334 3335 traceback.
3335 3336 \layout List
3336 3337 \labelwidthstring 00.00.0000
3337 3338
3338 3339 \SpecialChar ~
3339 3340 Verbose: similar to Context, but additionally prints the variables currently
3340 3341 visible where the exception happened (shortening their strings if too long).
3341 3342 This can potentially be very slow, if you happen to have a huge data structure
3342 3343 whose string representation is complex to compute.
3343 3344 Your computer may appear to freeze for a while with cpu usage at 100%.
3344 3345 If this occurs, you can cancel the traceback with Ctrl-C (maybe hitting
3345 3346 it more than once).
3346 3347 \layout Section
3347 3348
3348 3349 Interactive use
3349 3350 \layout Standard
3350 3351
3351 3352
3352 3353 \series bold
3353 3354 Warning
3354 3355 \series default
3355 3356 : IPython relies on the existence of a global variable called
3356 3357 \family typewriter
3357 3358 __IP
3358 3359 \family default
3359 3360 which controls the shell itself.
3360 3361 If you redefine
3361 3362 \family typewriter
3362 3363 __IP
3363 3364 \family default
3364 3365 to anything, bizarre behavior will quickly occur.
3365 3366 \layout Standard
3366 3367
3367 3368 Other than the above warning, IPython is meant to work as a drop-in replacement
3368 3369 for the standard interactive interpreter.
3369 3370 As such, any code which is valid python should execute normally under IPython
3370 3371 (cases where this is not true should be reported as bugs).
3371 3372 It does, however, offer many features which are not available at a standard
3372 3373 python prompt.
3373 3374 What follows is a list of these.
3374 3375 \layout Subsection
3375 3376
3376 3377 Caution for Windows users
3377 3378 \layout Standard
3378 3379
3379 3380 Windows, unfortunately, uses the `
3380 3381 \family typewriter
3381 3382
3382 3383 \backslash
3383 3384
3384 3385 \family default
3385 3386 ' character as a path separator.
3386 3387 This is a terrible choice, because `
3387 3388 \family typewriter
3388 3389
3389 3390 \backslash
3390 3391
3391 3392 \family default
3392 3393 ' also represents the escape character in most modern programming languages,
3393 3394 including Python.
3394 3395 For this reason, issuing many of the commands discussed below (especially
3395 3396 magics which affect the filesystem) with `
3396 3397 \family typewriter
3397 3398
3398 3399 \backslash
3399 3400
3400 3401 \family default
3401 3402 ' in them will cause strange errors.
3402 3403 \layout Standard
3403 3404
3404 3405 A partial solution is to use instead the `
3405 3406 \family typewriter
3406 3407 /
3407 3408 \family default
3408 3409 ' character as a path separator, which Windows recognizes in
3409 3410 \emph on
3410 3411 most
3411 3412 \emph default
3412 3413 situations.
3413 3414 However, in Windows commands `
3414 3415 \family typewriter
3415 3416 /
3416 3417 \family default
3417 3418 ' flags options, so you can not use it for the root directory.
3418 3419 This means that paths beginning at the root must be typed in a contrived
3419 3420 manner like:
3420 3421 \newline
3421 3422
3422 3423 \family typewriter
3423 3424 %copy
3424 3425 \backslash
3425 3426 opt/foo/bar.txt
3426 3427 \backslash
3427 3428 tmp
3428 3429 \layout Standard
3429 3430
3430 3431 There is no sensible thing IPython can do to truly work around this flaw
3431 3432 in Windows
3432 3433 \begin_inset Foot
3433 3434 collapsed true
3434 3435
3435 3436 \layout Standard
3436 3437
3437 3438 If anyone comes up with a
3438 3439 \emph on
3439 3440 clean
3440 3441 \emph default
3441 3442 solution which works consistently and does not negatively impact other
3442 3443 platforms at all, I'll gladly accept a patch.
3443 3444 \end_inset
3444 3445
3445 3446 .
3446 3447 \layout Subsection
3447 3448
3448 3449
3449 3450 \begin_inset LatexCommand \label{sec:magic}
3450 3451
3451 3452 \end_inset
3452 3453
3453 3454 Magic command system
3454 3455 \layout Standard
3455 3456
3456 3457 IPython will treat any line whose first character is a
3457 3458 \family typewriter
3458 3459 %
3459 3460 \family default
3460 3461 as a special call to a 'magic' function.
3461 3462 These allow you to control the behavior of IPython itself, plus a lot of
3462 3463 system-type features.
3463 3464 They are all prefixed with a
3464 3465 \family typewriter
3465 3466 %
3466 3467 \family default
3467 3468 character, but parameters are given without parentheses or quotes.
3468 3469 \layout Standard
3469 3470
3470 3471 Example: typing
3471 3472 \family typewriter
3472 3473 '%cd mydir'
3473 3474 \family default
3474 3475 (without the quotes) changes you working directory to
3475 3476 \family typewriter
3476 3477 'mydir'
3477 3478 \family default
3478 3479 , if it exists.
3479 3480 \layout Standard
3480 3481
3481 3482 If you have 'automagic' enabled (in your
3482 3483 \family typewriter
3483 3484 ipythonrc
3484 3485 \family default
3485 3486 file, via the command line option
3486 3487 \family typewriter
3487 3488 -automagic
3488 3489 \family default
3489 3490 or with the
3490 3491 \family typewriter
3491 3492 %automagic
3492 3493 \family default
3493 3494 function), you don't need to type in the
3494 3495 \family typewriter
3495 3496 %
3496 3497 \family default
3497 3498 explicitly.
3498 3499 IPython will scan its internal list of magic functions and call one if
3499 3500 it exists.
3500 3501 With automagic on you can then just type '
3501 3502 \family typewriter
3502 3503 cd mydir
3503 3504 \family default
3504 3505 ' to go to directory '
3505 3506 \family typewriter
3506 3507 mydir
3507 3508 \family default
3508 3509 '.
3509 3510 The automagic system has the lowest possible precedence in name searches,
3510 3511 so defining an identifier with the same name as an existing magic function
3511 3512 will shadow it for automagic use.
3512 3513 You can still access the shadowed magic function by explicitly using the
3513 3514
3514 3515 \family typewriter
3515 3516 %
3516 3517 \family default
3517 3518 character at the beginning of the line.
3518 3519 \layout Standard
3519 3520
3520 3521 An example (with automagic on) should clarify all this:
3521 3522 \layout LyX-Code
3522 3523
3523 3524 In [1]: cd ipython # %cd is called by automagic
3524 3525 \layout LyX-Code
3525 3526
3526 3527 /home/fperez/ipython
3527 3528 \layout LyX-Code
3528 3529
3529 3530 In [2]: cd=1 # now cd is just a variable
3530 3531 \layout LyX-Code
3531 3532
3532 3533 In [3]: cd ..
3533 3534 # and doesn't work as a function anymore
3534 3535 \layout LyX-Code
3535 3536
3536 3537 ------------------------------------------------------------
3537 3538 \layout LyX-Code
3538 3539
3539 3540 File "<console>", line 1
3540 3541 \layout LyX-Code
3541 3542
3542 3543 cd ..
3543 3544 \layout LyX-Code
3544 3545
3545 3546 ^
3546 3547 \layout LyX-Code
3547 3548
3548 3549 SyntaxError: invalid syntax
3549 3550 \layout LyX-Code
3550 3551
3551 3552 \layout LyX-Code
3552 3553
3553 3554 In [4]: %cd ..
3554 3555 # but %cd always works
3555 3556 \layout LyX-Code
3556 3557
3557 3558 /home/fperez
3558 3559 \layout LyX-Code
3559 3560
3560 3561 In [5]: del cd # if you remove the cd variable
3561 3562 \layout LyX-Code
3562 3563
3563 3564 In [6]: cd ipython # automagic can work again
3564 3565 \layout LyX-Code
3565 3566
3566 3567 /home/fperez/ipython
3567 3568 \layout Standard
3568 3569
3569 3570 You can define your own magic functions to extend the system.
3570 3571 The following is a snippet of code which shows how to do it.
3571 3572 It is provided as file
3572 3573 \family typewriter
3573 3574 example-magic.py
3574 3575 \family default
3575 3576 in the examples directory:
3576 3577 \layout Standard
3577 3578
3578 3579
3579 3580 \begin_inset Include \verbatiminput{examples/example-magic.py}
3580 3581 preview false
3581 3582
3582 3583 \end_inset
3583 3584
3584 3585
3585 3586 \layout Standard
3586 3587
3587 3588 You can also define your own aliased names for magic functions.
3588 3589 In your
3589 3590 \family typewriter
3590 3591 ipythonrc
3591 3592 \family default
3592 3593 file, placing a line like:
3593 3594 \layout Standard
3594 3595
3595 3596
3596 3597 \family typewriter
3597 3598 execute __IP.magic_cl = __IP.magic_clear
3598 3599 \layout Standard
3599 3600
3600 3601 will define
3601 3602 \family typewriter
3602 3603 %cl
3603 3604 \family default
3604 3605 as a new name for
3605 3606 \family typewriter
3606 3607 %clear
3607 3608 \family default
3608 3609 .
3609 3610 \layout Standard
3610 3611
3611 3612 Type
3612 3613 \family typewriter
3613 3614 %magic
3614 3615 \family default
3615 3616 for more information, including a list of all available magic functions
3616 3617 at any time and their docstrings.
3617 3618 You can also type
3618 3619 \family typewriter
3619 3620 %magic_function_name?
3620 3621 \family default
3621 3622 (see sec.
3622 3623
3623 3624 \begin_inset LatexCommand \ref{sec:dyn-object-info}
3624 3625
3625 3626 \end_inset
3626 3627
3627 3628 for information on the
3628 3629 \family typewriter
3629 3630 '?'
3630 3631 \family default
3631 3632 system) to get information about any particular magic function you are
3632 3633 interested in.
3633 3634 \layout Subsubsection
3634 3635
3635 3636 Magic commands
3636 3637 \layout Standard
3637 3638
3638 3639 The rest of this section is automatically generated for each release from
3639 3640 the docstrings in the IPython code.
3640 3641 Therefore the formatting is somewhat minimal, but this method has the advantage
3641 3642 of having information always in sync with the code.
3642 3643 \layout Standard
3643 3644
3644 3645 A list of all the magic commands available in IPython's
3645 3646 \emph on
3646 3647 default
3647 3648 \emph default
3648 3649 installation follows.
3649 3650 This is similar to what you'll see by simply typing
3650 3651 \family typewriter
3651 3652 %magic
3652 3653 \family default
3653 3654 at the prompt, but that will also give you information about magic commands
3654 3655 you may have added as part of your personal customizations.
3655 3656 \layout Standard
3656 3657
3657 3658
3658 3659 \begin_inset Include \input{magic.tex}
3659 3660 preview false
3660 3661
3661 3662 \end_inset
3662 3663
3663 3664
3664 3665 \layout Subsection
3665 3666
3666 3667 Access to the standard Python help
3667 3668 \layout Standard
3668 3669
3669 3670 As of Python 2.1, a help system is available with access to object docstrings
3670 3671 and the Python manuals.
3671 3672 Simply type
3672 3673 \family typewriter
3673 3674 'help'
3674 3675 \family default
3675 3676 (no quotes) to access it.
3676 3677 You can also type
3677 3678 \family typewriter
3678 3679 help(object)
3679 3680 \family default
3680 3681 to obtain information about a given object, and
3681 3682 \family typewriter
3682 3683 help('keyword')
3683 3684 \family default
3684 3685 for information on a keyword.
3685 3686 As noted in sec.
3686 3687
3687 3688 \begin_inset LatexCommand \ref{sec:help-access}
3688 3689
3689 3690 \end_inset
3690 3691
3691 3692 , you need to properly configure your environment variable
3692 3693 \family typewriter
3693 3694 PYTHONDOCS
3694 3695 \family default
3695 3696 for this feature to work correctly.
3696 3697 \layout Subsection
3697 3698
3698 3699
3699 3700 \begin_inset LatexCommand \label{sec:dyn-object-info}
3700 3701
3701 3702 \end_inset
3702 3703
3703 3704 Dynamic object information
3704 3705 \layout Standard
3705 3706
3706 3707 Typing
3707 3708 \family typewriter
3708 3709 ?word
3709 3710 \family default
3710 3711 or
3711 3712 \family typewriter
3712 3713 word?
3713 3714 \family default
3714 3715 prints detailed information about an object.
3715 3716 If certain strings in the object are too long (docstrings, code, etc.) they
3716 3717 get snipped in the center for brevity.
3717 3718 This system gives access variable types and values, full source code for
3718 3719 any object (if available), function prototypes and other useful information.
3719 3720 \layout Standard
3720 3721
3721 3722 Typing
3722 3723 \family typewriter
3723 3724 ??word
3724 3725 \family default
3725 3726 or
3726 3727 \family typewriter
3727 3728 word??
3728 3729 \family default
3729 3730 gives access to the full information without snipping long strings.
3730 3731 Long strings are sent to the screen through the
3731 3732 \family typewriter
3732 3733 less
3733 3734 \family default
3734 3735 pager if longer than the screen and printed otherwise.
3735 3736 On systems lacking the
3736 3737 \family typewriter
3737 3738 less
3738 3739 \family default
3739 3740 command, IPython uses a very basic internal pager.
3740 3741 \layout Standard
3741 3742
3742 3743 The following magic functions are particularly useful for gathering information
3743 3744 about your working environment.
3744 3745 You can get more details by typing
3745 3746 \family typewriter
3746 3747 %magic
3747 3748 \family default
3748 3749 or querying them individually (use
3749 3750 \family typewriter
3750 3751 %function_name?
3751 3752 \family default
3752 3753 with or without the
3753 3754 \family typewriter
3754 3755 %
3755 3756 \family default
3756 3757 ), this is just a summary:
3757 3758 \layout List
3758 3759 \labelwidthstring 00.00.0000
3759 3760
3760 3761
3761 3762 \family typewriter
3762 3763 \series bold
3763 3764 %pdoc\SpecialChar ~
3764 3765 <object>
3765 3766 \family default
3766 3767 \series default
3767 3768 : Print (or run through a pager if too long) the docstring for an object.
3768 3769 If the given object is a class, it will print both the class and the constructo
3769 3770 r docstrings.
3770 3771 \layout List
3771 3772 \labelwidthstring 00.00.0000
3772 3773
3773 3774
3774 3775 \family typewriter
3775 3776 \series bold
3776 3777 %pdef\SpecialChar ~
3777 3778 <object>
3778 3779 \family default
3779 3780 \series default
3780 3781 : Print the definition header for any callable object.
3781 3782 If the object is a class, print the constructor information.
3782 3783 \layout List
3783 3784 \labelwidthstring 00.00.0000
3784 3785
3785 3786
3786 3787 \family typewriter
3787 3788 \series bold
3788 3789 %psource\SpecialChar ~
3789 3790 <object>
3790 3791 \family default
3791 3792 \series default
3792 3793 : Print (or run through a pager if too long) the source code for an object.
3793 3794 \layout List
3794 3795 \labelwidthstring 00.00.0000
3795 3796
3796 3797
3797 3798 \family typewriter
3798 3799 \series bold
3799 3800 %pfile\SpecialChar ~
3800 3801 <object>
3801 3802 \family default
3802 3803 \series default
3803 3804 : Show the entire source file where an object was defined via a pager, opening
3804 3805 it at the line where the object definition begins.
3805 3806 \layout List
3806 3807 \labelwidthstring 00.00.0000
3807 3808
3808 3809
3809 3810 \family typewriter
3810 3811 \series bold
3811 3812 %who/%whos
3812 3813 \family default
3813 3814 \series default
3814 3815 : These functions give information about identifiers you have defined interactiv
3815 3816 ely (not things you loaded or defined in your configuration files).
3816 3817
3817 3818 \family typewriter
3818 3819 %who
3819 3820 \family default
3820 3821 just prints a list of identifiers and
3821 3822 \family typewriter
3822 3823 %whos
3823 3824 \family default
3824 3825 prints a table with some basic details about each identifier.
3825 3826 \layout Standard
3826 3827
3827 3828 Note that the dynamic object information functions (
3828 3829 \family typewriter
3829 3830 ?/??, %pdoc, %pfile, %pdef, %psource
3830 3831 \family default
3831 3832 ) give you access to documentation even on things which are not really defined
3832 3833 as separate identifiers.
3833 3834 Try for example typing
3834 3835 \family typewriter
3835 3836 {}.get?
3836 3837 \family default
3837 3838 or after doing
3838 3839 \family typewriter
3839 3840 import os
3840 3841 \family default
3841 3842 , type
3842 3843 \family typewriter
3843 3844 os.path.abspath??
3844 3845 \family default
3845 3846 .
3846 3847 \layout Subsection
3847 3848
3848 3849
3849 3850 \begin_inset LatexCommand \label{sec:readline}
3850 3851
3851 3852 \end_inset
3852 3853
3853 3854 Readline-based features
3854 3855 \layout Standard
3855 3856
3856 3857 These features require the GNU readline library, so they won't work if your
3857 3858 Python installation lacks readline support.
3858 3859 We will first describe the default behavior IPython uses, and then how
3859 3860 to change it to suit your preferences.
3860 3861 \layout Subsubsection
3861 3862
3862 3863 Command line completion
3863 3864 \layout Standard
3864 3865
3865 3866 At any time, hitting TAB will complete any available python commands or
3866 3867 variable names, and show you a list of the possible completions if there's
3867 3868 no unambiguous one.
3868 3869 It will also complete filenames in the current directory if no python names
3869 3870 match what you've typed so far.
3870 3871 \layout Subsubsection
3871 3872
3872 3873 Search command history
3873 3874 \layout Standard
3874 3875
3875 3876 IPython provides two ways for searching through previous input and thus
3876 3877 reduce the need for repetitive typing:
3877 3878 \layout Enumerate
3878 3879
3879 3880 Start typing, and then use
3880 3881 \family typewriter
3881 3882 Ctrl-p
3882 3883 \family default
3883 3884 (previous,up) and
3884 3885 \family typewriter
3885 3886 Ctrl-n
3886 3887 \family default
3887 3888 (next,down) to search through only the history items that match what you've
3888 3889 typed so far.
3889 3890 If you use
3890 3891 \family typewriter
3891 3892 Ctrl-p/Ctrl-n
3892 3893 \family default
3893 3894 at a blank prompt, they just behave like normal arrow keys.
3894 3895 \layout Enumerate
3895 3896
3896 3897 Hit
3897 3898 \family typewriter
3898 3899 Ctrl-r
3899 3900 \family default
3900 3901 : opens a search prompt.
3901 3902 Begin typing and the system searches your history for lines that contain
3902 3903 what you've typed so far, completing as much as it can.
3903 3904 \layout Subsubsection
3904 3905
3905 3906 Persistent command history across sessions
3906 3907 \layout Standard
3907 3908
3908 3909 IPython will save your input history when it leaves and reload it next time
3909 3910 you restart it.
3910 3911 By default, the history file is named
3911 3912 \family typewriter
3912 3913 $IPYTHONDIR/history
3913 3914 \family default
3914 3915 , but if you've loaded a named profile, '
3915 3916 \family typewriter
3916 3917 -PROFILE_NAME
3917 3918 \family default
3918 3919 ' is appended to the name.
3919 3920 This allows you to keep separate histories related to various tasks: commands
3920 3921 related to numerical work will not be clobbered by a system shell history,
3921 3922 for example.
3922 3923 \layout Subsubsection
3923 3924
3924 3925 Autoindent
3925 3926 \layout Standard
3926 3927
3927 3928 IPython can recognize lines ending in ':' and indent the next line, while
3928 3929 also un-indenting automatically after 'raise' or 'return'.
3929 3930
3930 3931 \layout Standard
3931 3932
3932 3933 This feature uses the readline library, so it will honor your
3933 3934 \family typewriter
3934 3935 ~/.inputrc
3935 3936 \family default
3936 3937 configuration (or whatever file your
3937 3938 \family typewriter
3938 3939 INPUTRC
3939 3940 \family default
3940 3941 variable points to).
3941 3942 Adding the following lines to your
3942 3943 \family typewriter
3943 3944 .inputrc
3944 3945 \family default
3945 3946 file can make indenting/unindenting more convenient (
3946 3947 \family typewriter
3947 3948 M-i
3948 3949 \family default
3949 3950 indents,
3950 3951 \family typewriter
3951 3952 M-u
3952 3953 \family default
3953 3954 unindents):
3954 3955 \layout Standard
3955 3956
3956 3957
3957 3958 \family typewriter
3958 3959 $if Python
3959 3960 \newline
3960 3961 "
3961 3962 \backslash
3962 3963 M-i": "\SpecialChar ~
3963 3964 \SpecialChar ~
3964 3965 \SpecialChar ~
3965 3966 \SpecialChar ~
3966 3967 "
3967 3968 \newline
3968 3969 "
3969 3970 \backslash
3970 3971 M-u": "
3971 3972 \backslash
3972 3973 d
3973 3974 \backslash
3974 3975 d
3975 3976 \backslash
3976 3977 d
3977 3978 \backslash
3978 3979 d"
3979 3980 \newline
3980 3981 $endif
3981 3982 \layout Standard
3982 3983
3983 3984 Note that there are 4 spaces between the quote marks after
3984 3985 \family typewriter
3985 3986 "M-i"
3986 3987 \family default
3987 3988 above.
3988 3989 \layout Standard
3989 3990
3990 3991
3991 3992 \series bold
3992 3993 Warning:
3993 3994 \series default
3994 3995 this feature is ON by default, but it can cause problems with the pasting
3995 3996 of multi-line indented code (the pasted code gets re-indented on each line).
3996 3997 A magic function
3997 3998 \family typewriter
3998 3999 %autoindent
3999 4000 \family default
4000 4001 allows you to toggle it on/off at runtime.
4001 4002 You can also disable it permanently on in your
4002 4003 \family typewriter
4003 4004 ipythonrc
4004 4005 \family default
4005 4006 file (set
4006 4007 \family typewriter
4007 4008 autoindent 0
4008 4009 \family default
4009 4010 ).
4010 4011 \layout Subsubsection
4011 4012
4012 4013 Customizing readline behavior
4013 4014 \layout Standard
4014 4015
4015 4016 All these features are based on the GNU readline library, which has an extremely
4016 4017 customizable interface.
4017 4018 Normally, readline is configured via a file which defines the behavior
4018 4019 of the library; the details of the syntax for this can be found in the
4019 4020 readline documentation available with your system or on the Internet.
4020 4021 IPython doesn't read this file (if it exists) directly, but it does support
4021 4022 passing to readline valid options via a simple interface.
4022 4023 In brief, you can customize readline by setting the following options in
4023 4024 your
4024 4025 \family typewriter
4025 4026 ipythonrc
4026 4027 \family default
4027 4028 configuration file (note that these options can
4028 4029 \emph on
4029 4030 not
4030 4031 \emph default
4031 4032 be specified at the command line):
4032 4033 \layout List
4033 4034 \labelwidthstring 00.00.0000
4034 4035
4035 4036
4036 4037 \family typewriter
4037 4038 \series bold
4038 4039 readline_parse_and_bind:
4039 4040 \family default
4040 4041 \series default
4041 4042 this option can appear as many times as you want, each time defining a
4042 4043 string to be executed via a
4043 4044 \family typewriter
4044 4045 readline.parse_and_bind()
4045 4046 \family default
4046 4047 command.
4047 4048 The syntax for valid commands of this kind can be found by reading the
4048 4049 documentation for the GNU readline library, as these commands are of the
4049 4050 kind which readline accepts in its configuration file.
4050 4051 \layout List
4051 4052 \labelwidthstring 00.00.0000
4052 4053
4053 4054
4054 4055 \family typewriter
4055 4056 \series bold
4056 4057 readline_remove_delims:
4057 4058 \family default
4058 4059 \series default
4059 4060 a string of characters to be removed from the default word-delimiters list
4060 4061 used by readline, so that completions may be performed on strings which
4061 4062 contain them.
4062 4063 Do not change the default value unless you know what you're doing.
4063 4064 \layout List
4064 4065 \labelwidthstring 00.00.0000
4065 4066
4066 4067
4067 4068 \family typewriter
4068 4069 \series bold
4069 4070 readline_omit__names
4070 4071 \family default
4071 4072 \series default
4072 4073 : when tab-completion is enabled, hitting
4073 4074 \family typewriter
4074 4075 <tab>
4075 4076 \family default
4076 4077 after a '
4077 4078 \family typewriter
4078 4079 .
4079 4080 \family default
4080 4081 ' in a name will complete all attributes of an object, including all the
4081 4082 special methods whose names include double underscores (like
4082 4083 \family typewriter
4083 4084 __getitem__
4084 4085 \family default
4085 4086 or
4086 4087 \family typewriter
4087 4088 __class__
4088 4089 \family default
4089 4090 ).
4090 4091 If you'd rather not see these names by default, you can set this option
4091 4092 to 1.
4092 4093 Note that even when this option is set, you can still see those names by
4093 4094 explicitly typing a
4094 4095 \family typewriter
4095 4096 _
4096 4097 \family default
4097 4098 after the period and hitting
4098 4099 \family typewriter
4099 4100 <tab>
4100 4101 \family default
4101 4102 : '
4102 4103 \family typewriter
4103 4104 name._<tab>
4104 4105 \family default
4105 4106 ' will always complete attribute names starting with '
4106 4107 \family typewriter
4107 4108 _
4108 4109 \family default
4109 4110 '.
4110 4111 \layout List
4111 4112 \labelwidthstring 00.00.0000
4112 4113
4113 4114 \SpecialChar ~
4114 4115 This option is off by default so that new users see all attributes of any
4115 4116 objects they are dealing with.
4116 4117 \layout Standard
4117 4118
4118 4119 You will find the default values along with a corresponding detailed explanation
4119 4120 in your
4120 4121 \family typewriter
4121 4122 ipythonrc
4122 4123 \family default
4123 4124 file.
4124 4125 \layout Subsection
4125 4126
4126 4127 Session logging and restoring
4127 4128 \layout Standard
4128 4129
4129 4130 You can log all input from a session either by starting IPython with the
4130 4131 command line switches
4131 4132 \family typewriter
4132 4133 -log
4133 4134 \family default
4134 4135 or
4135 4136 \family typewriter
4136 4137 -logfile
4137 4138 \family default
4138 4139 (see sec.
4139 4140
4140 4141 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
4141 4142
4142 4143 \end_inset
4143 4144
4144 4145 )or by activating the logging at any moment with the magic function
4145 4146 \family typewriter
4146 4147 %logstart
4147 4148 \family default
4148 4149 .
4149 4150
4150 4151 \layout Standard
4151 4152
4152 4153 Log files can later be reloaded with the
4153 4154 \family typewriter
4154 4155 -logplay
4155 4156 \family default
4156 4157 option and IPython will attempt to 'replay' the log by executing all the
4157 4158 lines in it, thus restoring the state of a previous session.
4158 4159 This feature is not quite perfect, but can still be useful in many cases.
4159 4160 \layout Standard
4160 4161
4161 4162 The log files can also be used as a way to have a permanent record of any
4162 4163 code you wrote while experimenting.
4163 4164 Log files are regular text files which you can later open in your favorite
4164 4165 text editor to extract code or to 'clean them up' before using them to
4165 4166 replay a session.
4166 4167 \layout Standard
4167 4168
4168 4169 The
4169 4170 \family typewriter
4170 4171 %logstart
4171 4172 \family default
4172 4173 function for activating logging in mid-session is used as follows:
4173 4174 \layout Standard
4174 4175
4175 4176
4176 4177 \family typewriter
4177 4178 %logstart [log_name [log_mode]]
4178 4179 \layout Standard
4179 4180
4180 4181 If no name is given, it defaults to a file named
4181 4182 \family typewriter
4182 4183 'log'
4183 4184 \family default
4184 4185 in your IPYTHONDIR directory, in
4185 4186 \family typewriter
4186 4187 'rotate'
4187 4188 \family default
4188 4189 mode (see below).
4189 4190 \layout Standard
4190 4191
4191 4192 '
4192 4193 \family typewriter
4193 4194 %logstart name
4194 4195 \family default
4195 4196 ' saves to file
4196 4197 \family typewriter
4197 4198 'name'
4198 4199 \family default
4199 4200 in
4200 4201 \family typewriter
4201 4202 'backup'
4202 4203 \family default
4203 4204 mode.
4204 4205 It saves your history up to that point and then continues logging.
4205 4206 \layout Standard
4206 4207
4207 4208
4208 4209 \family typewriter
4209 4210 %logstart
4210 4211 \family default
4211 4212 takes a second optional parameter: logging mode.
4212 4213 This can be one of (note that the modes are given unquoted):
4213 4214 \layout List
4214 4215 \labelwidthstring 00.00.0000
4215 4216
4216 4217
4217 4218 \family typewriter
4218 4219 over
4219 4220 \family default
4220 4221 : overwrite existing
4221 4222 \family typewriter
4222 4223 log_name
4223 4224 \family default
4224 4225 .
4225 4226 \layout List
4226 4227 \labelwidthstring 00.00.0000
4227 4228
4228 4229
4229 4230 \family typewriter
4230 4231 backup
4231 4232 \family default
4232 4233 : rename (if exists) to
4233 4234 \family typewriter
4234 4235 log_name~
4235 4236 \family default
4236 4237 and start
4237 4238 \family typewriter
4238 4239 log_name
4239 4240 \family default
4240 4241 .
4241 4242 \layout List
4242 4243 \labelwidthstring 00.00.0000
4243 4244
4244 4245
4245 4246 \family typewriter
4246 4247 append
4247 4248 \family default
4248 4249 : well, that says it.
4249 4250 \layout List
4250 4251 \labelwidthstring 00.00.0000
4251 4252
4252 4253
4253 4254 \family typewriter
4254 4255 rotate
4255 4256 \family default
4256 4257 : create rotating logs
4257 4258 \family typewriter
4258 4259 log_name
4259 4260 \family default
4260 4261 .
4261 4262 \family typewriter
4262 4263 1~
4263 4264 \family default
4264 4265 ,
4265 4266 \family typewriter
4266 4267 log_name.2~
4267 4268 \family default
4268 4269 , etc.
4269 4270 \layout Standard
4270 4271
4271 4272 The
4272 4273 \family typewriter
4273 4274 %logoff
4274 4275 \family default
4275 4276 and
4276 4277 \family typewriter
4277 4278 %logon
4278 4279 \family default
4279 4280 functions allow you to temporarily stop and resume logging to a file which
4280 4281 had previously been started with
4281 4282 \family typewriter
4282 4283 %logstart
4283 4284 \family default
4284 4285 .
4285 4286 They will fail (with an explanation) if you try to use them before logging
4286 4287 has been started.
4287 4288 \layout Subsection
4288 4289
4289 4290
4290 4291 \begin_inset LatexCommand \label{sub:System-shell-access}
4291 4292
4292 4293 \end_inset
4293 4294
4294 4295 System shell access
4295 4296 \layout Standard
4296 4297
4297 4298 Any input line beginning with a
4298 4299 \family typewriter
4299 4300 !
4300 4301 \family default
4301 4302 character is passed verbatim (minus the
4302 4303 \family typewriter
4303 4304 !
4304 4305 \family default
4305 4306 , of course) to the underlying operating system.
4306 4307 For example, typing
4307 4308 \family typewriter
4308 4309 !ls
4309 4310 \family default
4310 4311 will run
4311 4312 \family typewriter
4312 4313 'ls'
4313 4314 \family default
4314 4315 in the current directory.
4315 4316 \layout Subsubsection
4316 4317
4317 4318 Manual capture of command output
4318 4319 \layout Standard
4319 4320
4320 4321 If the input line begins with
4321 4322 \emph on
4322 4323 two
4323 4324 \emph default
4324 4325 exclamation marks,
4325 4326 \family typewriter
4326 4327 !!
4327 4328 \family default
4328 4329 , the command is executed but its output is captured and returned as a python
4329 4330 list, split on newlines.
4330 4331 Any output sent by the subprocess to standard error is printed separately,
4331 4332 so that the resulting list only captures standard output.
4332 4333 The
4333 4334 \family typewriter
4334 4335 !!
4335 4336 \family default
4336 4337 syntax is a shorthand for the
4337 4338 \family typewriter
4338 4339 %sx
4339 4340 \family default
4340 4341 magic command.
4341 4342 \layout Standard
4342 4343
4343 4344 Finally, the
4344 4345 \family typewriter
4345 4346 %sc
4346 4347 \family default
4347 4348 magic (short for `shell capture') is similar to
4348 4349 \family typewriter
4349 4350 %sx
4350 4351 \family default
4351 4352 , but allowing more fine-grained control of the capture details, and storing
4352 4353 the result directly into a named variable.
4353 4354 \layout Standard
4354 4355
4355 4356 See Sec.\SpecialChar ~
4356 4357
4357 4358 \begin_inset LatexCommand \ref{sec:magic}
4358 4359
4359 4360 \end_inset
4360 4361
4361 4362 for details on the magics
4362 4363 \family typewriter
4363 4364 %sc
4364 4365 \family default
4365 4366 and
4366 4367 \family typewriter
4367 4368 %sx
4368 4369 \family default
4369 4370 , or use IPython's own help (
4370 4371 \family typewriter
4371 4372 sc?
4372 4373 \family default
4373 4374 and
4374 4375 \family typewriter
4375 4376 sx?
4376 4377 \family default
4377 4378 ) for further details.
4378 4379 \layout Standard
4379 4380
4380 4381 IPython also allows you to expand the value of python variables when making
4381 4382 system calls.
4382 4383 Any python variable or expression which you prepend with
4383 4384 \family typewriter
4384 4385 $
4385 4386 \family default
4386 4387 will get expanded before the system call is made.
4387 4388
4388 4389 \layout Standard
4389 4390
4390 4391
4391 4392 \family typewriter
4392 4393 In [1]: pyvar='Hello world'
4393 4394 \newline
4394 4395 In [2]: !echo "A python variable: $pyvar"
4395 4396 \newline
4396 4397 A python variable: Hello world
4397 4398 \layout Standard
4398 4399
4399 4400 If you want the shell to actually see a literal
4400 4401 \family typewriter
4401 4402 $
4402 4403 \family default
4403 4404 , you need to type it twice:
4404 4405 \layout Standard
4405 4406
4406 4407
4407 4408 \family typewriter
4408 4409 In [3]: !echo "A system variable: $$HOME"
4409 4410 \newline
4410 4411 A system variable: /home/fperez
4411 4412 \layout Standard
4412 4413
4413 4414 You can pass arbitrary expressions, though you'll need to delimit them with
4414 4415
4415 4416 \family typewriter
4416 4417 {}
4417 4418 \family default
4418 4419 if there is ambiguity as to the extent of the expression:
4419 4420 \layout Standard
4420 4421
4421 4422
4422 4423 \family typewriter
4423 4424 In [5]: x=10
4424 4425 \newline
4425 4426 In [6]: y=20
4426 4427 \newline
4427 4428 In [13]: !echo $x+y
4428 4429 \newline
4429 4430 10+y
4430 4431 \newline
4431 4432 In [7]: !echo ${x+y}
4432 4433 \newline
4433 4434 30
4434 4435 \layout Standard
4435 4436
4436 4437 Even object attributes can be expanded:
4437 4438 \layout Standard
4438 4439
4439 4440
4440 4441 \family typewriter
4441 4442 In [12]: !echo $sys.argv
4442 4443 \newline
4443 4444 [/home/fperez/usr/bin/ipython]
4444 4445 \layout Subsection
4445 4446
4446 4447 System command aliases
4447 4448 \layout Standard
4448 4449
4449 4450 The
4450 4451 \family typewriter
4451 4452 %alias
4452 4453 \family default
4453 4454 magic function and the
4454 4455 \family typewriter
4455 4456 alias
4456 4457 \family default
4457 4458 option in the
4458 4459 \family typewriter
4459 4460 ipythonrc
4460 4461 \family default
4461 4462 configuration file allow you to define magic functions which are in fact
4462 4463 system shell commands.
4463 4464 These aliases can have parameters.
4464 4465
4465 4466 \layout Standard
4466 4467
4467 4468 '
4468 4469 \family typewriter
4469 4470 %alias alias_name cmd
4470 4471 \family default
4471 4472 ' defines '
4472 4473 \family typewriter
4473 4474 alias_name
4474 4475 \family default
4475 4476 ' as an alias for '
4476 4477 \family typewriter
4477 4478 cmd
4478 4479 \family default
4479 4480 '
4480 4481 \layout Standard
4481 4482
4482 4483 Then, typing '
4483 4484 \family typewriter
4484 4485 %alias_name params
4485 4486 \family default
4486 4487 ' will execute the system command '
4487 4488 \family typewriter
4488 4489 cmd params
4489 4490 \family default
4490 4491 ' (from your underlying operating system).
4491 4492
4492 4493 \layout Standard
4493 4494
4494 4495 You can also define aliases with parameters using
4495 4496 \family typewriter
4496 4497 %s
4497 4498 \family default
4498 4499 specifiers (one per parameter).
4499 4500 The following example defines the
4500 4501 \family typewriter
4501 4502 %parts
4502 4503 \family default
4503 4504 function as an alias to the command '
4504 4505 \family typewriter
4505 4506 echo first %s second %s
4506 4507 \family default
4507 4508 ' where each
4508 4509 \family typewriter
4509 4510 %s
4510 4511 \family default
4511 4512 will be replaced by a positional parameter to the call to
4512 4513 \family typewriter
4513 4514 %parts:
4514 4515 \layout Standard
4515 4516
4516 4517
4517 4518 \family typewriter
4518 4519 In [1]: alias parts echo first %s second %s
4519 4520 \newline
4520 4521 In [2]: %parts A B
4521 4522 \newline
4522 4523 first A second B
4523 4524 \newline
4524 4525 In [3]: %parts A
4525 4526 \newline
4526 4527 Incorrect number of arguments: 2 expected.
4527 4528
4528 4529 \newline
4529 4530 parts is an alias to: 'echo first %s second %s'
4530 4531 \layout Standard
4531 4532
4532 4533 If called with no parameters,
4533 4534 \family typewriter
4534 4535 %alias
4535 4536 \family default
4536 4537 prints the table of currently defined aliases.
4537 4538 \layout Standard
4538 4539
4539 4540 The
4540 4541 \family typewriter
4541 4542 %rehash/rehashx
4542 4543 \family default
4543 4544 magics allow you to load your entire
4544 4545 \family typewriter
4545 4546 $PATH
4546 4547 \family default
4547 4548 as ipython aliases.
4548 4549 See their respective docstrings (or sec.\SpecialChar ~
4549 4550
4550 4551 \begin_inset LatexCommand \ref{sec:magic}
4551 4552
4552 4553 \end_inset
4553 4554
4554 4555 for further details).
4555 4556 \layout Subsection
4556 4557
4557 4558
4558 4559 \begin_inset LatexCommand \label{sec:dreload}
4559 4560
4560 4561 \end_inset
4561 4562
4562 4563 Recursive reload
4563 4564 \layout Standard
4564 4565
4565 4566 The
4566 4567 \family typewriter
4567 4568 %dreload
4568 4569 \family default
4569 4570 command does a recursive reload of a module: changes made to the module
4570 4571 since you imported will actually be available without having to exit.
4571 4572 \layout Subsection
4572 4573
4573 4574 Verbose and colored exception traceback printouts
4574 4575 \layout Standard
4575 4576
4576 4577 IPython provides the option to see very detailed exception tracebacks, which
4577 4578 can be especially useful when debugging large programs.
4578 4579 You can run any Python file with the
4579 4580 \family typewriter
4580 4581 %run
4581 4582 \family default
4582 4583 function to benefit from these detailed tracebacks.
4583 4584 Furthermore, both normal and verbose tracebacks can be colored (if your
4584 4585 terminal supports it) which makes them much easier to parse visually.
4585 4586 \layout Standard
4586 4587
4587 4588 See the magic
4588 4589 \family typewriter
4589 4590 xmode
4590 4591 \family default
4591 4592 and
4592 4593 \family typewriter
4593 4594 colors
4594 4595 \family default
4595 4596 functions for details (just type
4596 4597 \family typewriter
4597 4598 %magic
4598 4599 \family default
4599 4600 ).
4600 4601 \layout Standard
4601 4602
4602 4603 These features are basically a terminal version of Ka-Ping Yee's
4603 4604 \family typewriter
4604 4605 cgitb
4605 4606 \family default
4606 4607 module, now part of the standard Python library.
4607 4608 \layout Subsection
4608 4609
4609 4610
4610 4611 \begin_inset LatexCommand \label{sec:cache_input}
4611 4612
4612 4613 \end_inset
4613 4614
4614 4615 Input caching system
4615 4616 \layout Standard
4616 4617
4617 4618 IPython offers numbered prompts (In/Out) with input and output caching.
4618 4619 All input is saved and can be retrieved as variables (besides the usual
4619 4620 arrow key recall).
4620 4621 \layout Standard
4621 4622
4622 4623 The following GLOBAL variables always exist (so don't overwrite them!):
4623 4624
4624 4625 \family typewriter
4625 4626 _i
4626 4627 \family default
4627 4628 : stores previous input.
4628 4629
4629 4630 \family typewriter
4630 4631 _ii
4631 4632 \family default
4632 4633 : next previous.
4633 4634
4634 4635 \family typewriter
4635 4636 _iii
4636 4637 \family default
4637 4638 : next-next previous.
4638 4639
4639 4640 \family typewriter
4640 4641 _ih
4641 4642 \family default
4642 4643 : a list of all input
4643 4644 \family typewriter
4644 4645 _ih[n]
4645 4646 \family default
4646 4647 is the input from line
4647 4648 \family typewriter
4648 4649 n
4649 4650 \family default
4650 4651 and this list is aliased to the global variable
4651 4652 \family typewriter
4652 4653 In
4653 4654 \family default
4654 4655 .
4655 4656 If you overwrite
4656 4657 \family typewriter
4657 4658 In
4658 4659 \family default
4659 4660 with a variable of your own, you can remake the assignment to the internal
4660 4661 list with a simple
4661 4662 \family typewriter
4662 4663 'In=_ih'
4663 4664 \family default
4664 4665 .
4665 4666 \layout Standard
4666 4667
4667 4668 Additionally, global variables named
4668 4669 \family typewriter
4669 4670 _i<n>
4670 4671 \family default
4671 4672 are dynamically created (
4672 4673 \family typewriter
4673 4674 <n>
4674 4675 \family default
4675 4676 being the prompt counter), such that
4676 4677 \newline
4677 4678
4678 4679 \family typewriter
4679 4680 _i<n> == _ih[<n>] == In[<n>].
4680 4681 \layout Standard
4681 4682
4682 4683 For example, what you typed at prompt 14 is available as
4683 4684 \family typewriter
4684 4685 _i14,
4685 4686 \family default
4686 4687
4687 4688 \family typewriter
4688 4689 _ih[14]
4689 4690 \family default
4690 4691 and
4691 4692 \family typewriter
4692 4693 In[14]
4693 4694 \family default
4694 4695 .
4695 4696 \layout Standard
4696 4697
4697 4698 This allows you to easily cut and paste multi line interactive prompts by
4698 4699 printing them out: they print like a clean string, without prompt characters.
4699 4700 You can also manipulate them like regular variables (they are strings),
4700 4701 modify or exec them (typing
4701 4702 \family typewriter
4702 4703 'exec _i9'
4703 4704 \family default
4704 4705 will re-execute the contents of input prompt 9, '
4705 4706 \family typewriter
4706 4707 exec In[9:14]+In[18]
4707 4708 \family default
4708 4709 ' will re-execute lines 9 through 13 and line 18).
4709 4710 \layout Standard
4710 4711
4711 4712 You can also re-execute multiple lines of input easily by using the magic
4712 4713
4713 4714 \family typewriter
4714 4715 %macro
4715 4716 \family default
4716 4717 function (which automates the process and allows re-execution without having
4717 4718 to type '
4718 4719 \family typewriter
4719 4720 exec
4720 4721 \family default
4721 4722 ' every time).
4722 4723 The macro system also allows you to re-execute previous lines which include
4723 4724 magic function calls (which require special processing).
4724 4725 Type
4725 4726 \family typewriter
4726 4727 %macro?
4727 4728 \family default
4728 4729 or see sec.
4729 4730
4730 4731 \begin_inset LatexCommand \ref{sec:magic}
4731 4732
4732 4733 \end_inset
4733 4734
4734 4735 for more details on the macro system.
4735 4736 \layout Standard
4736 4737
4737 4738 A history function
4738 4739 \family typewriter
4739 4740 %hist
4740 4741 \family default
4741 4742 allows you to see any part of your input history by printing a range of
4742 4743 the
4743 4744 \family typewriter
4744 4745 _i
4745 4746 \family default
4746 4747 variables.
4747 4748 \layout Subsection
4748 4749
4749 4750
4750 4751 \begin_inset LatexCommand \label{sec:cache_output}
4751 4752
4752 4753 \end_inset
4753 4754
4754 4755 Output caching system
4755 4756 \layout Standard
4756 4757
4757 4758 For output that is returned from actions, a system similar to the input
4758 4759 cache exists but using
4759 4760 \family typewriter
4760 4761 _
4761 4762 \family default
4762 4763 instead of
4763 4764 \family typewriter
4764 4765 _i
4765 4766 \family default
4766 4767 .
4767 4768 Only actions that produce a result (NOT assignments, for example) are cached.
4768 4769 If you are familiar with Mathematica, IPython's
4769 4770 \family typewriter
4770 4771 _
4771 4772 \family default
4772 4773 variables behave exactly like Mathematica's
4773 4774 \family typewriter
4774 4775 %
4775 4776 \family default
4776 4777 variables.
4777 4778 \layout Standard
4778 4779
4779 4780 The following GLOBAL variables always exist (so don't overwrite them!):
4780 4781
4781 4782 \layout List
4782 4783 \labelwidthstring 00.00.0000
4783 4784
4784 4785
4785 4786 \family typewriter
4786 4787 \series bold
4787 4788 _
4788 4789 \family default
4789 4790 \series default
4790 4791 (a
4791 4792 \emph on
4792 4793 single
4793 4794 \emph default
4794 4795 underscore) : stores previous output, like Python's default interpreter.
4795 4796 \layout List
4796 4797 \labelwidthstring 00.00.0000
4797 4798
4798 4799
4799 4800 \family typewriter
4800 4801 \series bold
4801 4802 __
4802 4803 \family default
4803 4804 \series default
4804 4805 (two underscores): next previous.
4805 4806 \layout List
4806 4807 \labelwidthstring 00.00.0000
4807 4808
4808 4809
4809 4810 \family typewriter
4810 4811 \series bold
4811 4812 ___
4812 4813 \family default
4813 4814 \series default
4814 4815 (three underscores): next-next previous.
4815 4816 \layout Standard
4816 4817
4817 4818 Additionally, global variables named
4818 4819 \family typewriter
4819 4820 _<n>
4820 4821 \family default
4821 4822 are dynamically created (
4822 4823 \family typewriter
4823 4824 <n>
4824 4825 \family default
4825 4826 being the prompt counter), such that the result of output
4826 4827 \family typewriter
4827 4828 <n>
4828 4829 \family default
4829 4830 is always available as
4830 4831 \family typewriter
4831 4832 _<n>
4832 4833 \family default
4833 4834 (don't use the angle brackets, just the number, e.g.
4834 4835
4835 4836 \family typewriter
4836 4837 _21
4837 4838 \family default
4838 4839 ).
4839 4840 \layout Standard
4840 4841
4841 4842 These global variables are all stored in a global dictionary (not a list,
4842 4843 since it only has entries for lines which returned a result) available
4843 4844 under the names
4844 4845 \family typewriter
4845 4846 _oh
4846 4847 \family default
4847 4848 and
4848 4849 \family typewriter
4849 4850 Out
4850 4851 \family default
4851 4852 (similar to
4852 4853 \family typewriter
4853 4854 _ih
4854 4855 \family default
4855 4856 and
4856 4857 \family typewriter
4857 4858 In
4858 4859 \family default
4859 4860 ).
4860 4861 So the output from line 12 can be obtained as
4861 4862 \family typewriter
4862 4863 _12
4863 4864 \family default
4864 4865 ,
4865 4866 \family typewriter
4866 4867 Out[12]
4867 4868 \family default
4868 4869 or
4869 4870 \family typewriter
4870 4871 _oh[12]
4871 4872 \family default
4872 4873 .
4873 4874 If you accidentally overwrite the
4874 4875 \family typewriter
4875 4876 Out
4876 4877 \family default
4877 4878 variable you can recover it by typing
4878 4879 \family typewriter
4879 4880 'Out=_oh
4880 4881 \family default
4881 4882 ' at the prompt.
4882 4883 \layout Standard
4883 4884
4884 4885 This system obviously can potentially put heavy memory demands on your system,
4885 4886 since it prevents Python's garbage collector from removing any previously
4886 4887 computed results.
4887 4888 You can control how many results are kept in memory with the option (at
4888 4889 the command line or in your
4889 4890 \family typewriter
4890 4891 ipythonrc
4891 4892 \family default
4892 4893 file)
4893 4894 \family typewriter
4894 4895 cache_size
4895 4896 \family default
4896 4897 .
4897 4898 If you set it to 0, the whole system is completely disabled and the prompts
4898 4899 revert to the classic
4899 4900 \family typewriter
4900 4901 '>>>'
4901 4902 \family default
4902 4903 of normal Python.
4903 4904 \layout Subsection
4904 4905
4905 4906 Directory history
4906 4907 \layout Standard
4907 4908
4908 4909 Your history of visited directories is kept in the global list
4909 4910 \family typewriter
4910 4911 _dh
4911 4912 \family default
4912 4913 , and the magic
4913 4914 \family typewriter
4914 4915 %cd
4915 4916 \family default
4916 4917 command can be used to go to any entry in that list.
4917 4918 The
4918 4919 \family typewriter
4919 4920 %dhist
4920 4921 \family default
4921 4922 command allows you to view this history.
4922 4923 \layout Subsection
4923 4924
4924 4925 Automatic parentheses and quotes
4925 4926 \layout Standard
4926 4927
4927 4928 These features were adapted from Nathan Gray's LazyPython.
4928 4929 They are meant to allow less typing for common situations.
4929 4930 \layout Subsubsection
4930 4931
4931 4932 Automatic parentheses
4932 4933 \layout Standard
4933 4934
4934 4935 Callable objects (i.e.
4935 4936 functions, methods, etc) can be invoked like this (notice the commas between
4936 4937 the arguments):
4937 4938 \layout Standard
4938 4939
4939 4940
4940 4941 \family typewriter
4941 4942 >>> callable_ob arg1, arg2, arg3
4942 4943 \layout Standard
4943 4944
4944 4945 and the input will be translated to this:
4945 4946 \layout Standard
4946 4947
4947 4948
4948 4949 \family typewriter
4949 4950 --> callable_ob(arg1, arg2, arg3)
4950 4951 \layout Standard
4951 4952
4952 4953 You can force automatic parentheses by using '/' as the first character
4953 4954 of a line.
4954 4955 For example:
4955 4956 \layout Standard
4956 4957
4957 4958
4958 4959 \family typewriter
4959 4960 >>> /globals # becomes 'globals()'
4960 4961 \layout Standard
4961 4962
4962 4963 Note that the '/' MUST be the first character on the line! This won't work:
4963 4964
4964 4965 \layout Standard
4965 4966
4966 4967
4967 4968 \family typewriter
4968 4969 >>> print /globals # syntax error
4969 4970 \layout Standard
4970 4971
4971 4972 In most cases the automatic algorithm should work, so you should rarely
4972 4973 need to explicitly invoke /.
4973 4974 One notable exception is if you are trying to call a function with a list
4974 4975 of tuples as arguments (the parenthesis will confuse IPython):
4975 4976 \layout Standard
4976 4977
4977 4978
4978 4979 \family typewriter
4979 4980 In [1]: zip (1,2,3),(4,5,6) # won't work
4980 4981 \layout Standard
4981 4982
4982 4983 but this will work:
4983 4984 \layout Standard
4984 4985
4985 4986
4986 4987 \family typewriter
4987 4988 In [2]: /zip (1,2,3),(4,5,6)
4988 4989 \newline
4989 4990 ------> zip ((1,2,3),(4,5,6))
4990 4991 \newline
4991 4992 Out[2]= [(1, 4), (2, 5), (3, 6)]
4992 4993 \layout Standard
4993 4994
4994 4995 IPython tells you that it has altered your command line by displaying the
4995 4996 new command line preceded by
4996 4997 \family typewriter
4997 4998 -->
4998 4999 \family default
4999 5000 .
5000 5001 e.g.:
5001 5002 \layout Standard
5002 5003
5003 5004
5004 5005 \family typewriter
5005 5006 In [18]: callable list
5006 5007 \newline
5007 5008 -------> callable (list)
5008 5009 \layout Subsubsection
5009 5010
5010 5011 Automatic quoting
5011 5012 \layout Standard
5012 5013
5013 5014 You can force automatic quoting of a function's arguments by using
5014 5015 \family typewriter
5015 5016 `,'
5016 5017 \family default
5017 5018 or
5018 5019 \family typewriter
5019 5020 `;'
5020 5021 \family default
5021 5022 as the first character of a line.
5022 5023 For example:
5023 5024 \layout Standard
5024 5025
5025 5026
5026 5027 \family typewriter
5027 5028 >>> ,my_function /home/me # becomes my_function("/home/me")
5028 5029 \layout Standard
5029 5030
5030 5031 If you use
5031 5032 \family typewriter
5032 5033 `;'
5033 5034 \family default
5034 5035 instead, the whole argument is quoted as a single string (while
5035 5036 \family typewriter
5036 5037 `,'
5037 5038 \family default
5038 5039 splits on whitespace):
5039 5040 \layout Standard
5040 5041
5041 5042
5042 5043 \family typewriter
5043 5044 >>> ,my_function a b c # becomes my_function("a","b","c")
5044 5045 \layout Standard
5045 5046
5046 5047
5047 5048 \family typewriter
5048 5049 >>> ;my_function a b c # becomes my_function("a b c")
5049 5050 \layout Standard
5050 5051
5051 5052 Note that the `
5052 5053 \family typewriter
5053 5054 ,
5054 5055 \family default
5055 5056 ' or `
5056 5057 \family typewriter
5057 5058 ;
5058 5059 \family default
5059 5060 ' MUST be the first character on the line! This won't work:
5060 5061 \layout Standard
5061 5062
5062 5063
5063 5064 \family typewriter
5064 5065 >>> x = ,my_function /home/me # syntax error
5065 5066 \layout Section
5066 5067
5067 5068
5068 5069 \begin_inset LatexCommand \label{sec:customization}
5069 5070
5070 5071 \end_inset
5071 5072
5072 5073 Customization
5073 5074 \layout Standard
5074 5075
5075 5076 As we've already mentioned, IPython reads a configuration file which can
5076 5077 be specified at the command line (
5077 5078 \family typewriter
5078 5079 -rcfile
5079 5080 \family default
5080 5081 ) or which by default is assumed to be called
5081 5082 \family typewriter
5082 5083 ipythonrc
5083 5084 \family default
5084 5085 .
5085 5086 Such a file is looked for in the current directory where IPython is started
5086 5087 and then in your
5087 5088 \family typewriter
5088 5089 IPYTHONDIR
5089 5090 \family default
5090 5091 , which allows you to have local configuration files for specific projects.
5091 5092 In this section we will call these types of configuration files simply
5092 5093 rcfiles (short for resource configuration file).
5093 5094 \layout Standard
5094 5095
5095 5096 The syntax of an rcfile is one of key-value pairs separated by whitespace,
5096 5097 one per line.
5097 5098 Lines beginning with a
5098 5099 \family typewriter
5099 5100 #
5100 5101 \family default
5101 5102 are ignored as comments, but comments can
5102 5103 \series bold
5103 5104 not
5104 5105 \series default
5105 5106 be put on lines with data (the parser is fairly primitive).
5106 5107 Note that these are not python files, and this is deliberate, because it
5107 5108 allows us to do some things which would be quite tricky to implement if
5108 5109 they were normal python files.
5109 5110 \layout Standard
5110 5111
5111 5112 First, an rcfile can contain permanent default values for almost all command
5112 5113 line options (except things like
5113 5114 \family typewriter
5114 5115 -help
5115 5116 \family default
5116 5117 or
5117 5118 \family typewriter
5118 5119 -Version
5119 5120 \family default
5120 5121 ).
5121 5122 Sec\SpecialChar ~
5122 5123
5123 5124 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
5124 5125
5125 5126 \end_inset
5126 5127
5127 5128 contains a description of all command-line options.
5128 5129 However, values you explicitly specify at the command line override the
5129 5130 values defined in the rcfile.
5130 5131 \layout Standard
5131 5132
5132 5133 Besides command line option values, the rcfile can specify values for certain
5133 5134 extra special options which are not available at the command line.
5134 5135 These options are briefly described below.
5135 5136
5136 5137 \layout Standard
5137 5138
5138 5139 Each of these options may appear as many times as you need it in the file.
5139 5140 \layout List
5140 5141 \labelwidthstring 00.00.0000
5141 5142
5142 5143
5143 5144 \family typewriter
5144 5145 \series bold
5145 5146 include\SpecialChar ~
5146 5147 <file1>\SpecialChar ~
5147 5148 <file2>\SpecialChar ~
5148 5149 ...
5149 5150 \family default
5150 5151 \series default
5151 5152 : you can name
5152 5153 \emph on
5153 5154 other
5154 5155 \emph default
5155 5156 rcfiles you want to recursively load up to 15 levels (don't use the
5156 5157 \family typewriter
5157 5158 <>
5158 5159 \family default
5159 5160 brackets in your names!).
5160 5161 This feature allows you to define a 'base' rcfile with general options
5161 5162 and special-purpose files which can be loaded only when needed with particular
5162 5163 configuration options.
5163 5164 To make this more convenient, IPython accepts the
5164 5165 \family typewriter
5165 5166 -profile <name>
5166 5167 \family default
5167 5168 option (abbreviates to
5168 5169 \family typewriter
5169 5170 -p <name
5170 5171 \family default
5171 5172 >)
5172 5173 \family typewriter
5173 5174 which
5174 5175 \family default
5175 5176 tells it to look for an rcfile named
5176 5177 \family typewriter
5177 5178 ipythonrc-<name>
5178 5179 \family default
5179 5180 .
5180 5181
5181 5182 \layout List
5182 5183 \labelwidthstring 00.00.0000
5183 5184
5184 5185
5185 5186 \family typewriter
5186 5187 \series bold
5187 5188 import_mod\SpecialChar ~
5188 5189 <mod1>\SpecialChar ~
5189 5190 <mod2>\SpecialChar ~
5190 5191 ...
5191 5192 \family default
5192 5193 \series default
5193 5194 : import modules with '
5194 5195 \family typewriter
5195 5196 import
5196 5197 \family default
5197 5198
5198 5199 \family typewriter
5199 5200 <mod1>,<mod2>,...
5200 5201 \family default
5201 5202 '
5202 5203 \layout List
5203 5204 \labelwidthstring 00.00.0000
5204 5205
5205 5206
5206 5207 \family typewriter
5207 5208 \series bold
5208 5209 import_some\SpecialChar ~
5209 5210 <mod>\SpecialChar ~
5210 5211 <f1>\SpecialChar ~
5211 5212 <f2>\SpecialChar ~
5212 5213 ...
5213 5214 \family default
5214 5215 \series default
5215 5216 : import functions with '
5216 5217 \family typewriter
5217 5218 from <mod> import
5218 5219 \family default
5219 5220
5220 5221 \family typewriter
5221 5222 <f1>,<f2>,...
5222 5223 \family default
5223 5224 '
5224 5225 \layout List
5225 5226 \labelwidthstring 00.00.0000
5226 5227
5227 5228
5228 5229 \family typewriter
5229 5230 \series bold
5230 5231 import_all\SpecialChar ~
5231 5232 <mod1>\SpecialChar ~
5232 5233 <mod2>\SpecialChar ~
5233 5234 ...
5234 5235 \family default
5235 5236 \series default
5236 5237 : for each module listed import functions with '
5237 5238 \family typewriter
5238 5239 from <mod> import *
5239 5240 \family default
5240 5241 '
5241 5242 \layout List
5242 5243 \labelwidthstring 00.00.0000
5243 5244
5244 5245
5245 5246 \family typewriter
5246 5247 \series bold
5247 5248 execute\SpecialChar ~
5248 5249 <python\SpecialChar ~
5249 5250 code>
5250 5251 \family default
5251 5252 \series default
5252 5253 : give any single-line python code to be executed.
5253 5254 \layout List
5254 5255 \labelwidthstring 00.00.0000
5255 5256
5256 5257
5257 5258 \family typewriter
5258 5259 \series bold
5259 5260 execfile\SpecialChar ~
5260 5261 <filename>
5261 5262 \family default
5262 5263 \series default
5263 5264 : execute the python file given with an '
5264 5265 \family typewriter
5265 5266 execfile(filename)
5266 5267 \family default
5267 5268 ' command.
5268 5269 Username expansion is performed on the given names.
5269 5270 So if you need any amount of extra fancy customization that won't fit in
5270 5271 any of the above 'canned' options, you can just put it in a separate python
5271 5272 file and execute it.
5272 5273 \layout List
5273 5274 \labelwidthstring 00.00.0000
5274 5275
5275 5276
5276 5277 \family typewriter
5277 5278 \series bold
5278 5279 alias\SpecialChar ~
5279 5280 <alias_def>
5280 5281 \family default
5281 5282 \series default
5282 5283 : this is equivalent to calling '
5283 5284 \family typewriter
5284 5285 %alias\SpecialChar ~
5285 5286 <alias_def>
5286 5287 \family default
5287 5288 ' at the IPython command line.
5288 5289 This way, from within IPython you can do common system tasks without having
5289 5290 to exit it or use the
5290 5291 \family typewriter
5291 5292 !
5292 5293 \family default
5293 5294 escape.
5294 5295 IPython isn't meant to be a shell replacement, but it is often very useful
5295 5296 to be able to do things with files while testing code.
5296 5297 This gives you the flexibility to have within IPython any aliases you may
5297 5298 be used to under your normal system shell.
5298 5299 \layout Subsection
5299 5300
5300 5301
5301 5302 \begin_inset LatexCommand \label{sec:ipytonrc-sample}
5302 5303
5303 5304 \end_inset
5304 5305
5305 5306 Sample
5306 5307 \family typewriter
5307 5308 ipythonrc
5308 5309 \family default
5309 5310 file
5310 5311 \layout Standard
5311 5312
5312 5313 The default rcfile, called
5313 5314 \family typewriter
5314 5315 ipythonrc
5315 5316 \family default
5316 5317 and supplied in your
5317 5318 \family typewriter
5318 5319 IPYTHONDIR
5319 5320 \family default
5320 5321 directory contains lots of comments on all of these options.
5321 5322 We reproduce it here for reference:
5322 5323 \layout Standard
5323 5324
5324 5325
5325 5326 \begin_inset Include \verbatiminput{../IPython/UserConfig/ipythonrc}
5326 5327 preview false
5327 5328
5328 5329 \end_inset
5329 5330
5330 5331
5331 5332 \layout Subsection
5332 5333
5333 5334
5334 5335 \begin_inset LatexCommand \label{sec:prompts}
5335 5336
5336 5337 \end_inset
5337 5338
5338 5339 Fine-tuning your prompt
5339 5340 \layout Standard
5340 5341
5341 5342 IPython's prompts can be customized using a syntax similar to that of the
5342 5343
5343 5344 \family typewriter
5344 5345 bash
5345 5346 \family default
5346 5347 shell.
5347 5348 Many of
5348 5349 \family typewriter
5349 5350 bash
5350 5351 \family default
5351 5352 's escapes are supported, as well as a few additional ones.
5352 5353 We list them below:
5353 5354 \layout Description
5354 5355
5355 5356
5356 5357 \backslash
5357 5358 # the prompt/history count number
5358 5359 \layout Description
5359 5360
5360 5361
5361 5362 \backslash
5362 5363 D the prompt/history count, with the actual digits replaced by dots.
5363 5364 Used mainly in continuation prompts (prompt_in2)
5364 5365 \layout Description
5365 5366
5366 5367
5367 5368 \backslash
5368 5369 w the current working directory
5369 5370 \layout Description
5370 5371
5371 5372
5372 5373 \backslash
5373 5374 W the basename of current working directory
5374 5375 \layout Description
5375 5376
5376 5377
5377 5378 \backslash
5378 5379 X
5379 5380 \emph on
5380 5381 n
5381 5382 \emph default
5382 5383 where
5383 5384 \begin_inset Formula $n=0\ldots5.$
5384 5385 \end_inset
5385 5386
5386 5387 The current working directory, with
5387 5388 \family typewriter
5388 5389 $HOME
5389 5390 \family default
5390 5391 replaced by
5391 5392 \family typewriter
5392 5393 ~
5393 5394 \family default
5394 5395 , and filtered out to contain only
5395 5396 \begin_inset Formula $n$
5396 5397 \end_inset
5397 5398
5398 5399 path elements
5399 5400 \layout Description
5400 5401
5401 5402
5402 5403 \backslash
5403 5404 Y
5404 5405 \emph on
5405 5406 n
5406 5407 \emph default
5407 5408 Similar to
5408 5409 \backslash
5409 5410 X
5410 5411 \emph on
5411 5412 n
5412 5413 \emph default
5413 5414 , but with the
5414 5415 \begin_inset Formula $n+1$
5415 5416 \end_inset
5416 5417
5417 5418 element included if it is
5418 5419 \family typewriter
5419 5420 ~
5420 5421 \family default
5421 5422 (this is similar to the behavior of the %c
5422 5423 \emph on
5423 5424 n
5424 5425 \emph default
5425 5426 escapes in
5426 5427 \family typewriter
5427 5428 tcsh
5428 5429 \family default
5429 5430 )
5430 5431 \layout Description
5431 5432
5432 5433
5433 5434 \backslash
5434 5435 u the username of the current user
5435 5436 \layout Description
5436 5437
5437 5438
5438 5439 \backslash
5439 5440 $ if the effective UID is 0, a #, otherwise a $
5440 5441 \layout Description
5441 5442
5442 5443
5443 5444 \backslash
5444 5445 h the hostname up to the first `.'
5445 5446 \layout Description
5446 5447
5447 5448
5448 5449 \backslash
5449 5450 H the hostname
5450 5451 \layout Description
5451 5452
5452 5453
5453 5454 \backslash
5454 5455 n a newline
5455 5456 \layout Description
5456 5457
5457 5458
5458 5459 \backslash
5459 5460 r a carriage return
5460 5461 \layout Description
5461 5462
5462 5463
5463 5464 \backslash
5464 5465 v IPython version string
5465 5466 \layout Standard
5466 5467
5467 5468 In addition to these, ANSI color escapes can be insterted into the prompts,
5468 5469 as
5469 5470 \family typewriter
5470 5471
5471 5472 \backslash
5472 5473 C_
5473 5474 \emph on
5474 5475 ColorName
5475 5476 \family default
5476 5477 \emph default
5477 5478 .
5478 5479 The list of valid color names is: Black, Blue, Brown, Cyan, DarkGray, Green,
5479 5480 LightBlue, LightCyan, LightGray, LightGreen, LightPurple, LightRed, NoColor,
5480 5481 Normal, Purple, Red, White, Yellow.
5481 5482 \layout Standard
5482 5483
5483 5484 Finally, IPython supports the evaluation of arbitrary expressions in your
5484 5485 prompt string.
5485 5486 The prompt strings are evaluated through the syntax of PEP 215, but basically
5486 5487 you can use
5487 5488 \family typewriter
5488 5489 $x.y
5489 5490 \family default
5490 5491 to expand the value of
5491 5492 \family typewriter
5492 5493 x.y
5493 5494 \family default
5494 5495 , and for more complicated expressions you can use braces:
5495 5496 \family typewriter
5496 5497 ${foo()+x}
5497 5498 \family default
5498 5499 will call function
5499 5500 \family typewriter
5500 5501 foo
5501 5502 \family default
5502 5503 and add to it the value of
5503 5504 \family typewriter
5504 5505 x
5505 5506 \family default
5506 5507 , before putting the result into your prompt.
5507 5508 For example, using
5508 5509 \newline
5509 5510
5510 5511 \family typewriter
5511 5512 prompt_in1 '${commands.getoutput("uptime")}
5512 5513 \backslash
5513 5514 nIn [
5514 5515 \backslash
5515 5516 #]: '
5516 5517 \newline
5517 5518
5518 5519 \family default
5519 5520 will print the result of the uptime command on each prompt (assuming the
5520 5521
5521 5522 \family typewriter
5522 5523 commands
5523 5524 \family default
5524 5525 module has been imported in your
5525 5526 \family typewriter
5526 5527 ipythonrc
5527 5528 \family default
5528 5529 file).
5529 5530 \layout Subsubsection
5530 5531
5531 5532 Prompt examples
5532 5533 \layout Standard
5533 5534
5534 5535 The following options in an ipythonrc file will give you IPython's default
5535 5536 prompts:
5536 5537 \layout Standard
5537 5538
5538 5539
5539 5540 \family typewriter
5540 5541 prompt_in1 'In [
5541 5542 \backslash
5542 5543 #]:'
5543 5544 \newline
5544 5545 prompt_in2 '\SpecialChar ~
5545 5546 \SpecialChar ~
5546 5547 \SpecialChar ~
5547 5548 .
5548 5549 \backslash
5549 5550 D.:'
5550 5551 \newline
5551 5552 prompt_out 'Out[
5552 5553 \backslash
5553 5554 #]:'
5554 5555 \layout Standard
5555 5556
5556 5557 which look like this:
5557 5558 \layout Standard
5558 5559
5559 5560
5560 5561 \family typewriter
5561 5562 In [1]: 1+2
5562 5563 \newline
5563 5564 Out[1]: 3
5564 5565 \layout Standard
5565 5566
5566 5567
5567 5568 \family typewriter
5568 5569 In [2]: for i in (1,2,3):
5569 5570 \newline
5570 5571
5571 5572 \begin_inset ERT
5572 5573 status Collapsed
5573 5574
5574 5575 \layout Standard
5575 5576
5576 5577 \backslash
5577 5578 hspace*{0mm}
5578 5579 \end_inset
5579 5580
5580 5581 \SpecialChar ~
5581 5582 \SpecialChar ~
5582 5583 \SpecialChar ~
5583 5584 ...: \SpecialChar ~
5584 5585 \SpecialChar ~
5585 5586 \SpecialChar ~
5586 5587 \SpecialChar ~
5587 5588 print i,
5588 5589 \newline
5589 5590
5590 5591 \begin_inset ERT
5591 5592 status Collapsed
5592 5593
5593 5594 \layout Standard
5594 5595
5595 5596 \backslash
5596 5597 hspace*{0mm}
5597 5598 \end_inset
5598 5599
5599 5600 \SpecialChar ~
5600 5601 \SpecialChar ~
5601 5602 \SpecialChar ~
5602 5603 ...:
5603 5604 \newline
5604 5605 1 2 3
5605 5606 \layout Standard
5606 5607
5607 5608 These will give you a very colorful prompt with path information:
5608 5609 \layout Standard
5609 5610
5610 5611
5611 5612 \family typewriter
5612 5613 #prompt_in1 '
5613 5614 \backslash
5614 5615 C_Red
5615 5616 \backslash
5616 5617 u
5617 5618 \backslash
5618 5619 C_Blue[
5619 5620 \backslash
5620 5621 C_Cyan
5621 5622 \backslash
5622 5623 Y1
5623 5624 \backslash
5624 5625 C_Blue]
5625 5626 \backslash
5626 5627 C_LightGreen
5627 5628 \backslash
5628 5629 #>'
5629 5630 \newline
5630 5631 prompt_in2 ' ..
5631 5632 \backslash
5632 5633 D>'
5633 5634 \newline
5634 5635 prompt_out '<
5635 5636 \backslash
5636 5637 #>'
5637 5638 \layout Standard
5638 5639
5639 5640 which look like this:
5640 5641 \layout Standard
5641 5642
5642 5643
5643 5644 \family typewriter
5644 5645 \color red
5645 5646 fperez
5646 5647 \color blue
5647 5648 [
5648 5649 \color cyan
5649 5650 ~/ipython
5650 5651 \color blue
5651 5652 ]
5652 5653 \color green
5653 5654 1>
5654 5655 \color default
5655 5656 1+2
5656 5657 \newline
5657 5658
5658 5659 \begin_inset ERT
5659 5660 status Collapsed
5660 5661
5661 5662 \layout Standard
5662 5663
5663 5664 \backslash
5664 5665 hspace*{0mm}
5665 5666 \end_inset
5666 5667
5667 5668 \SpecialChar ~
5668 5669 \SpecialChar ~
5669 5670 \SpecialChar ~
5670 5671 \SpecialChar ~
5671 5672 \SpecialChar ~
5672 5673 \SpecialChar ~
5673 5674 \SpecialChar ~
5674 5675 \SpecialChar ~
5675 5676 \SpecialChar ~
5676 5677 \SpecialChar ~
5677 5678 \SpecialChar ~
5678 5679 \SpecialChar ~
5679 5680 \SpecialChar ~
5680 5681 \SpecialChar ~
5681 5682 \SpecialChar ~
5682 5683 \SpecialChar ~
5683 5684
5684 5685 \color red
5685 5686 <1>
5686 5687 \color default
5687 5688 3
5688 5689 \newline
5689 5690
5690 5691 \color red
5691 5692 fperez
5692 5693 \color blue
5693 5694 [
5694 5695 \color cyan
5695 5696 ~/ipython
5696 5697 \color blue
5697 5698 ]
5698 5699 \color green
5699 5700 2>
5700 5701 \color default
5701 5702 for i in (1,2,3):
5702 5703 \newline
5703 5704
5704 5705 \begin_inset ERT
5705 5706 status Collapsed
5706 5707
5707 5708 \layout Standard
5708 5709
5709 5710 \backslash
5710 5711 hspace*{0mm}
5711 5712 \end_inset
5712 5713
5713 5714 \SpecialChar ~
5714 5715 \SpecialChar ~
5715 5716 \SpecialChar ~
5716 5717 \SpecialChar ~
5717 5718 \SpecialChar ~
5718 5719 \SpecialChar ~
5719 5720 \SpecialChar ~
5720 5721 \SpecialChar ~
5721 5722 \SpecialChar ~
5722 5723 \SpecialChar ~
5723 5724 \SpecialChar ~
5724 5725 \SpecialChar ~
5725 5726 \SpecialChar ~
5726 5727 \SpecialChar ~
5727 5728 \SpecialChar ~
5728 5729
5729 5730 \color green
5730 5731 ...>
5731 5732 \color default
5732 5733 \SpecialChar ~
5733 5734 \SpecialChar ~
5734 5735 \SpecialChar ~
5735 5736 \SpecialChar ~
5736 5737 print i,
5737 5738 \newline
5738 5739
5739 5740 \begin_inset ERT
5740 5741 status Collapsed
5741 5742
5742 5743 \layout Standard
5743 5744
5744 5745 \backslash
5745 5746 hspace*{0mm}
5746 5747 \end_inset
5747 5748
5748 5749 \SpecialChar ~
5749 5750 \SpecialChar ~
5750 5751 \SpecialChar ~
5751 5752 \SpecialChar ~
5752 5753 \SpecialChar ~
5753 5754 \SpecialChar ~
5754 5755 \SpecialChar ~
5755 5756 \SpecialChar ~
5756 5757 \SpecialChar ~
5757 5758 \SpecialChar ~
5758 5759 \SpecialChar ~
5759 5760 \SpecialChar ~
5760 5761 \SpecialChar ~
5761 5762 \SpecialChar ~
5762 5763 \SpecialChar ~
5763 5764
5764 5765 \color green
5765 5766 ...>
5766 5767 \color default
5767 5768
5768 5769 \newline
5769 5770 1 2 3
5770 5771 \layout Standard
5771 5772
5772 5773 The following shows the usage of dynamic expression evaluation:
5773 5774 \layout Subsection
5774 5775
5775 5776
5776 5777 \begin_inset LatexCommand \label{sec:profiles}
5777 5778
5778 5779 \end_inset
5779 5780
5780 5781 IPython profiles
5781 5782 \layout Standard
5782 5783
5783 5784 As we already mentioned, IPython supports the
5784 5785 \family typewriter
5785 5786 -profile
5786 5787 \family default
5787 5788 command-line option (see sec.
5788 5789
5789 5790 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
5790 5791
5791 5792 \end_inset
5792 5793
5793 5794 ).
5794 5795 A profile is nothing more than a particular configuration file like your
5795 5796 basic
5796 5797 \family typewriter
5797 5798 ipythonrc
5798 5799 \family default
5799 5800 one, but with particular customizations for a specific purpose.
5800 5801 When you start IPython with '
5801 5802 \family typewriter
5802 5803 ipython -profile <name>
5803 5804 \family default
5804 5805 ', it assumes that in your
5805 5806 \family typewriter
5806 5807 IPYTHONDIR
5807 5808 \family default
5808 5809 there is a file called
5809 5810 \family typewriter
5810 5811 ipythonrc-<name>
5811 5812 \family default
5812 5813 , and loads it instead of the normal
5813 5814 \family typewriter
5814 5815 ipythonrc
5815 5816 \family default
5816 5817 .
5817 5818 \layout Standard
5818 5819
5819 5820 This system allows you to maintain multiple configurations which load modules,
5820 5821 set options, define functions, etc.
5821 5822 suitable for different tasks and activate them in a very simple manner.
5822 5823 In order to avoid having to repeat all of your basic options (common things
5823 5824 that don't change such as your color preferences, for example), any profile
5824 5825 can include another configuration file.
5825 5826 The most common way to use profiles is then to have each one include your
5826 5827 basic
5827 5828 \family typewriter
5828 5829 ipythonrc
5829 5830 \family default
5830 5831 file as a starting point, and then add further customizations.
5831 5832 \layout Standard
5832 5833
5833 5834 In sections
5834 5835 \begin_inset LatexCommand \ref{sec:syntax-extensions}
5835 5836
5836 5837 \end_inset
5837 5838
5838 5839 and
5839 5840 \begin_inset LatexCommand \ref{sec:Gnuplot}
5840 5841
5841 5842 \end_inset
5842 5843
5843 5844 we discuss some particular profiles which come as part of the standard
5844 5845 IPython distribution.
5845 5846 You may also look in your
5846 5847 \family typewriter
5847 5848 IPYTHONDIR
5848 5849 \family default
5849 5850 directory, any file whose name begins with
5850 5851 \family typewriter
5851 5852 ipythonrc-
5852 5853 \family default
5853 5854 is a profile.
5854 5855 You can use those as examples for further customizations to suit your own
5855 5856 needs.
5856 5857 \layout Section
5857 5858
5858 5859
5859 5860 \begin_inset OptArg
5860 5861 collapsed false
5861 5862
5862 5863 \layout Standard
5863 5864
5864 5865 IPython as default...
5865 5866 \end_inset
5866 5867
5867 5868 IPython as your default Python environment
5868 5869 \layout Standard
5869 5870
5870 5871 Python honors the environment variable
5871 5872 \family typewriter
5872 5873 PYTHONSTARTUP
5873 5874 \family default
5874 5875 and will execute at startup the file referenced by this variable.
5875 5876 If you put at the end of this file the following two lines of code:
5876 5877 \layout Standard
5877 5878
5878 5879
5879 5880 \family typewriter
5880 5881 import IPython
5881 5882 \newline
5882 5883 IPython.Shell.IPShell().mainloop(sys_exit=1)
5883 5884 \layout Standard
5884 5885
5885 5886 then IPython will be your working environment anytime you start Python.
5886 5887 The
5887 5888 \family typewriter
5888 5889 sys_exit=1
5889 5890 \family default
5890 5891 is needed to have IPython issue a call to
5891 5892 \family typewriter
5892 5893 sys.exit()
5893 5894 \family default
5894 5895 when it finishes, otherwise you'll be back at the normal Python '
5895 5896 \family typewriter
5896 5897 >>>
5897 5898 \family default
5898 5899 ' prompt
5899 5900 \begin_inset Foot
5900 5901 collapsed true
5901 5902
5902 5903 \layout Standard
5903 5904
5904 5905 Based on an idea by Holger Krekel.
5905 5906 \end_inset
5906 5907
5907 5908 .
5908 5909 \layout Standard
5909 5910
5910 5911 This is probably useful to developers who manage multiple Python versions
5911 5912 and don't want to have correspondingly multiple IPython versions.
5912 5913 Note that in this mode, there is no way to pass IPython any command-line
5913 5914 options, as those are trapped first by Python itself.
5914 5915 \layout Section
5915 5916
5916 5917
5917 5918 \begin_inset LatexCommand \label{sec:embed}
5918 5919
5919 5920 \end_inset
5920 5921
5921 5922 Embedding IPython
5922 5923 \layout Standard
5923 5924
5924 5925 It is possible to start an IPython instance
5925 5926 \emph on
5926 5927 inside
5927 5928 \emph default
5928 5929 your own Python programs.
5929 5930 This allows you to evaluate dynamically the state of your code, operate
5930 5931 with your variables, analyze them, etc.
5931 5932 Note however that any changes you make to values while in the shell do
5932 5933
5933 5934 \emph on
5934 5935 not
5935 5936 \emph default
5936 5937 propagate back to the running code, so it is safe to modify your values
5937 5938 because you won't break your code in bizarre ways by doing so.
5938 5939 \layout Standard
5939 5940
5940 5941 This feature allows you to easily have a fully functional python environment
5941 5942 for doing object introspection anywhere in your code with a simple function
5942 5943 call.
5943 5944 In some cases a simple print statement is enough, but if you need to do
5944 5945 more detailed analysis of a code fragment this feature can be very valuable.
5945 5946 \layout Standard
5946 5947
5947 5948 It can also be useful in scientific computing situations where it is common
5948 5949 to need to do some automatic, computationally intensive part and then stop
5949 5950 to look at data, plots, etc
5950 5951 \begin_inset Foot
5951 5952 collapsed true
5952 5953
5953 5954 \layout Standard
5954 5955
5955 5956 This functionality was inspired by IDL's combination of the
5956 5957 \family typewriter
5957 5958 stop
5958 5959 \family default
5959 5960 keyword and the
5960 5961 \family typewriter
5961 5962 .continue
5962 5963 \family default
5963 5964 executive command, which I have found very useful in the past, and by a
5964 5965 posting on comp.lang.python by cmkl <cmkleffner-AT-gmx.de> on Dec.
5965 5966 06/01 concerning similar uses of pyrepl.
5966 5967 \end_inset
5967 5968
5968 5969 .
5969 5970 Opening an IPython instance will give you full access to your data and
5970 5971 functions, and you can resume program execution once you are done with
5971 5972 the interactive part (perhaps to stop again later, as many times as needed).
5972 5973 \layout Standard
5973 5974
5974 5975 The following code snippet is the bare minimum you need to include in your
5975 5976 Python programs for this to work (detailed examples follow later):
5976 5977 \layout LyX-Code
5977 5978
5978 5979 from IPython.Shell import IPShellEmbed
5979 5980 \layout LyX-Code
5980 5981
5981 5982 ipshell = IPShellEmbed()
5982 5983 \layout LyX-Code
5983 5984
5984 5985 ipshell() # this call anywhere in your program will start IPython
5985 5986 \layout Standard
5986 5987
5987 5988 You can run embedded instances even in code which is itself being run at
5988 5989 the IPython interactive prompt with '
5989 5990 \family typewriter
5990 5991 %run\SpecialChar ~
5991 5992 <filename>
5992 5993 \family default
5993 5994 '.
5994 5995 Since it's easy to get lost as to where you are (in your top-level IPython
5995 5996 or in your embedded one), it's a good idea in such cases to set the in/out
5996 5997 prompts to something different for the embedded instances.
5997 5998 The code examples below illustrate this.
5998 5999 \layout Standard
5999 6000
6000 6001 You can also have multiple IPython instances in your program and open them
6001 6002 separately, for example with different options for data presentation.
6002 6003 If you close and open the same instance multiple times, its prompt counters
6003 6004 simply continue from each execution to the next.
6004 6005 \layout Standard
6005 6006
6006 6007 Please look at the docstrings in the
6007 6008 \family typewriter
6008 6009 Shell.py
6009 6010 \family default
6010 6011 module for more details on the use of this system.
6011 6012 \layout Standard
6012 6013
6013 6014 The following sample file illustrating how to use the embedding functionality
6014 6015 is provided in the examples directory as
6015 6016 \family typewriter
6016 6017 example-embed.py
6017 6018 \family default
6018 6019 .
6019 6020 It should be fairly self-explanatory:
6020 6021 \layout Standard
6021 6022
6022 6023
6023 6024 \begin_inset Include \verbatiminput{examples/example-embed.py}
6024 6025 preview false
6025 6026
6026 6027 \end_inset
6027 6028
6028 6029
6029 6030 \layout Standard
6030 6031
6031 6032 Once you understand how the system functions, you can use the following
6032 6033 code fragments in your programs which are ready for cut and paste:
6033 6034 \layout Standard
6034 6035
6035 6036
6036 6037 \begin_inset Include \verbatiminput{examples/example-embed-short.py}
6037 6038 preview false
6038 6039
6039 6040 \end_inset
6040 6041
6041 6042
6042 6043 \layout Section
6043 6044
6044 6045
6045 6046 \begin_inset LatexCommand \label{sec:using-pdb}
6046 6047
6047 6048 \end_inset
6048 6049
6049 6050 Using the Python debugger (
6050 6051 \family typewriter
6051 6052 pdb
6052 6053 \family default
6053 6054 )
6054 6055 \layout Subsection
6055 6056
6056 6057 Running entire programs via
6057 6058 \family typewriter
6058 6059 pdb
6059 6060 \layout Standard
6060 6061
6061 6062
6062 6063 \family typewriter
6063 6064 pdb
6064 6065 \family default
6065 6066 , the Python debugger, is a powerful interactive debugger which allows you
6066 6067 to step through code, set breakpoints, watch variables, etc.
6067 6068 IPython makes it very easy to start any script under the control of
6068 6069 \family typewriter
6069 6070 pdb
6070 6071 \family default
6071 6072 , regardless of whether you have wrapped it into a
6072 6073 \family typewriter
6073 6074 `main()'
6074 6075 \family default
6075 6076 function or not.
6076 6077 For this, simply type
6077 6078 \family typewriter
6078 6079 `%run -d myscript'
6079 6080 \family default
6080 6081 at an IPython prompt.
6081 6082 See the
6082 6083 \family typewriter
6083 6084 %run
6084 6085 \family default
6085 6086 command's documentation (via
6086 6087 \family typewriter
6087 6088 `%run?'
6088 6089 \family default
6089 6090 or in Sec.\SpecialChar ~
6090 6091
6091 6092 \begin_inset LatexCommand \ref{sec:magic}
6092 6093
6093 6094 \end_inset
6094 6095
6095 6096 ) for more details, including how to control where
6096 6097 \family typewriter
6097 6098 pdb
6098 6099 \family default
6099 6100 will stop execution first.
6100 6101 \layout Standard
6101 6102
6102 6103 For more information on the use of the
6103 6104 \family typewriter
6104 6105 pdb
6105 6106 \family default
6106 6107 debugger, read the included
6107 6108 \family typewriter
6108 6109 pdb.doc
6109 6110 \family default
6110 6111 file (part of the standard Python distribution).
6111 6112 On a stock Linux system it is located at
6112 6113 \family typewriter
6113 6114 /usr/lib/python2.3/pdb.doc
6114 6115 \family default
6115 6116 , but the easiest way to read it is by using the
6116 6117 \family typewriter
6117 6118 help()
6118 6119 \family default
6119 6120 function of the
6120 6121 \family typewriter
6121 6122 pdb
6122 6123 \family default
6123 6124 module as follows (in an IPython prompt):
6124 6125 \layout Standard
6125 6126
6126 6127
6127 6128 \family typewriter
6128 6129 In [1]: import pdb
6129 6130 \newline
6130 6131 In [2]: pdb.help()
6131 6132 \layout Standard
6132 6133
6133 6134 This will load the
6134 6135 \family typewriter
6135 6136 pdb.doc
6136 6137 \family default
6137 6138 document in a file viewer for you automatically.
6138 6139 \layout Subsection
6139 6140
6140 6141 Automatic invocation of
6141 6142 \family typewriter
6142 6143 pdb
6143 6144 \family default
6144 6145 on exceptions
6145 6146 \layout Standard
6146 6147
6147 6148 IPython, if started with the
6148 6149 \family typewriter
6149 6150 -pdb
6150 6151 \family default
6151 6152 option (or if the option is set in your rc file) can call the Python
6152 6153 \family typewriter
6153 6154 pdb
6154 6155 \family default
6155 6156 debugger every time your code triggers an uncaught exception
6156 6157 \begin_inset Foot
6157 6158 collapsed true
6158 6159
6159 6160 \layout Standard
6160 6161
6161 6162 Many thanks to Christopher Hart for the request which prompted adding this
6162 6163 feature to IPython.
6163 6164 \end_inset
6164 6165
6165 6166 .
6166 6167 This feature can also be toggled at any time with the
6167 6168 \family typewriter
6168 6169 %pdb
6169 6170 \family default
6170 6171 magic command.
6171 6172 This can be extremely useful in order to find the origin of subtle bugs,
6172 6173 because
6173 6174 \family typewriter
6174 6175 pdb
6175 6176 \family default
6176 6177 opens up at the point in your code which triggered the exception, and while
6177 6178 your program is at this point `dead', all the data is still available and
6178 6179 you can walk up and down the stack frame and understand the origin of the
6179 6180 problem.
6180 6181 \layout Standard
6181 6182
6182 6183 Furthermore, you can use these debugging facilities both with the embedded
6183 6184 IPython mode and without IPython at all.
6184 6185 For an embedded shell (see sec.
6185 6186
6186 6187 \begin_inset LatexCommand \ref{sec:embed}
6187 6188
6188 6189 \end_inset
6189 6190
6190 6191 ), simply call the constructor with
6191 6192 \family typewriter
6192 6193 `-pdb'
6193 6194 \family default
6194 6195 in the argument string and automatically
6195 6196 \family typewriter
6196 6197 pdb
6197 6198 \family default
6198 6199 will be called if an uncaught exception is triggered by your code.
6199 6200
6200 6201 \layout Standard
6201 6202
6202 6203 For stand-alone use of the feature in your programs which do not use IPython
6203 6204 at all, put the following lines toward the top of your `main' routine:
6204 6205 \layout Standard
6205 6206 \align left
6206 6207
6207 6208 \family typewriter
6208 6209 import sys,IPython.ultraTB
6209 6210 \newline
6210 6211 sys.excepthook = IPython.ultraTB.FormattedTB(mode=`Verbose', color_scheme=`Linux',
6211 6212 call_pdb=1)
6212 6213 \layout Standard
6213 6214
6214 6215 The
6215 6216 \family typewriter
6216 6217 mode
6217 6218 \family default
6218 6219 keyword can be either
6219 6220 \family typewriter
6220 6221 `Verbose'
6221 6222 \family default
6222 6223 or
6223 6224 \family typewriter
6224 6225 `Plain'
6225 6226 \family default
6226 6227 , giving either very detailed or normal tracebacks respectively.
6227 6228 The
6228 6229 \family typewriter
6229 6230 color_scheme
6230 6231 \family default
6231 6232 keyword can be one of
6232 6233 \family typewriter
6233 6234 `NoColor'
6234 6235 \family default
6235 6236 ,
6236 6237 \family typewriter
6237 6238 `Linux'
6238 6239 \family default
6239 6240 (default) or
6240 6241 \family typewriter
6241 6242 `LightBG'
6242 6243 \family default
6243 6244 .
6244 6245 These are the same options which can be set in IPython with
6245 6246 \family typewriter
6246 6247 -colors
6247 6248 \family default
6248 6249 and
6249 6250 \family typewriter
6250 6251 -xmode
6251 6252 \family default
6252 6253 .
6253 6254 \layout Standard
6254 6255
6255 6256 This will give any of your programs detailed, colored tracebacks with automatic
6256 6257 invocation of
6257 6258 \family typewriter
6258 6259 pdb
6259 6260 \family default
6260 6261 .
6261 6262 \layout Section
6262 6263
6263 6264
6264 6265 \begin_inset LatexCommand \label{sec:syntax-extensions}
6265 6266
6266 6267 \end_inset
6267 6268
6268 6269 Extensions for syntax processing
6269 6270 \layout Standard
6270 6271
6271 6272 This isn't for the faint of heart, because the potential for breaking things
6272 6273 is quite high.
6273 6274 But it can be a very powerful and useful feature.
6274 6275 In a nutshell, you can redefine the way IPython processes the user input
6275 6276 line to accept new, special extensions to the syntax without needing to
6276 6277 change any of IPython's own code.
6277 6278 \layout Standard
6278 6279
6279 6280 In the
6280 6281 \family typewriter
6281 6282 IPython/Extensions
6282 6283 \family default
6283 6284 directory you will find some examples supplied, which we will briefly describe
6284 6285 now.
6285 6286 These can be used `as is' (and both provide very useful functionality),
6286 6287 or you can use them as a starting point for writing your own extensions.
6287 6288 \layout Subsection
6288 6289
6289 6290 Pasting of code starting with
6290 6291 \family typewriter
6291 6292 `>>>
6292 6293 \family default
6293 6294 ' or
6294 6295 \family typewriter
6295 6296 `...
6296 6297
6297 6298 \family default
6298 6299 '
6299 6300 \layout Standard
6300 6301
6301 6302 In the python tutorial it is common to find code examples which have been
6302 6303 taken from real python sessions.
6303 6304 The problem with those is that all the lines begin with either
6304 6305 \family typewriter
6305 6306 `>>>
6306 6307 \family default
6307 6308 ' or
6308 6309 \family typewriter
6309 6310 `...
6310 6311
6311 6312 \family default
6312 6313 ', which makes it impossible to paste them all at once.
6313 6314 One must instead do a line by line manual copying, carefully removing the
6314 6315 leading extraneous characters.
6315 6316 \layout Standard
6316 6317
6317 6318 This extension identifies those starting characters and removes them from
6318 6319 the input automatically, so that one can paste multi-line examples directly
6319 6320 into IPython, saving a lot of time.
6320 6321 Please look at the file
6321 6322 \family typewriter
6322 6323 InterpreterPasteInput.py
6323 6324 \family default
6324 6325 in the
6325 6326 \family typewriter
6326 6327 IPython/Extensions
6327 6328 \family default
6328 6329 directory for details on how this is done.
6329 6330 \layout Standard
6330 6331
6331 6332 IPython comes with a special profile enabling this feature, called
6332 6333 \family typewriter
6333 6334 tutorial
6334 6335 \family default
6335 6336 \emph on
6336 6337 .
6337 6338
6338 6339 \emph default
6339 6340 Simply start IPython via
6340 6341 \family typewriter
6341 6342 `ipython\SpecialChar ~
6342 6343 -p\SpecialChar ~
6343 6344 tutorial'
6344 6345 \family default
6345 6346 and the feature will be available.
6346 6347 In a normal IPython session you can activate the feature by importing the
6347 6348 corresponding module with:
6348 6349 \newline
6349 6350
6350 6351 \family typewriter
6351 6352 In [1]: import IPython.Extensions.InterpreterPasteInput
6352 6353 \layout Standard
6353 6354
6354 6355 The following is a 'screenshot' of how things work when this extension is
6355 6356 on, copying an example from the standard tutorial:
6356 6357 \layout Standard
6357 6358
6358 6359
6359 6360 \family typewriter
6360 6361 IPython profile: tutorial
6361 6362 \newline
6362 6363 \SpecialChar ~
6363 6364
6364 6365 \newline
6365 6366 *** Pasting of code with ">>>" or "..." has been enabled.
6366 6367 \newline
6367 6368 \SpecialChar ~
6368 6369
6369 6370 \newline
6370 6371 In [1]: >>> def fib2(n): # return Fibonacci series up to n
6371 6372 \newline
6372 6373
6373 6374 \begin_inset ERT
6374 6375 status Collapsed
6375 6376
6376 6377 \layout Standard
6377 6378
6378 6379 \backslash
6379 6380 hspace*{0mm}
6380 6381 \end_inset
6381 6382
6382 6383 \SpecialChar ~
6383 6384 \SpecialChar ~
6384 6385 ...: ...\SpecialChar ~
6385 6386 \SpecialChar ~
6386 6387 \SpecialChar ~
6387 6388 \SpecialChar ~
6388 6389 """Return a list containing the Fibonacci series up to n."""
6389 6390 \newline
6390 6391
6391 6392 \begin_inset ERT
6392 6393 status Collapsed
6393 6394
6394 6395 \layout Standard
6395 6396
6396 6397 \backslash
6397 6398 hspace*{0mm}
6398 6399 \end_inset
6399 6400
6400 6401 \SpecialChar ~
6401 6402 \SpecialChar ~
6402 6403 ...: ...\SpecialChar ~
6403 6404 \SpecialChar ~
6404 6405 \SpecialChar ~
6405 6406 \SpecialChar ~
6406 6407 result = []
6407 6408 \newline
6408 6409
6409 6410 \begin_inset ERT
6410 6411 status Collapsed
6411 6412
6412 6413 \layout Standard
6413 6414
6414 6415 \backslash
6415 6416 hspace*{0mm}
6416 6417 \end_inset
6417 6418
6418 6419 \SpecialChar ~
6419 6420 \SpecialChar ~
6420 6421 ...: ...\SpecialChar ~
6421 6422 \SpecialChar ~
6422 6423 \SpecialChar ~
6423 6424 \SpecialChar ~
6424 6425 a, b = 0, 1
6425 6426 \newline
6426 6427
6427 6428 \begin_inset ERT
6428 6429 status Collapsed
6429 6430
6430 6431 \layout Standard
6431 6432
6432 6433 \backslash
6433 6434 hspace*{0mm}
6434 6435 \end_inset
6435 6436
6436 6437 \SpecialChar ~
6437 6438 \SpecialChar ~
6438 6439 ...: ...\SpecialChar ~
6439 6440 \SpecialChar ~
6440 6441 \SpecialChar ~
6441 6442 \SpecialChar ~
6442 6443 while b < n:
6443 6444 \newline
6444 6445
6445 6446 \begin_inset ERT
6446 6447 status Collapsed
6447 6448
6448 6449 \layout Standard
6449 6450
6450 6451 \backslash
6451 6452 hspace*{0mm}
6452 6453 \end_inset
6453 6454
6454 6455 \SpecialChar ~
6455 6456 \SpecialChar ~
6456 6457 ...: ...\SpecialChar ~
6457 6458 \SpecialChar ~
6458 6459 \SpecialChar ~
6459 6460 \SpecialChar ~
6460 6461 \SpecialChar ~
6461 6462 \SpecialChar ~
6462 6463 \SpecialChar ~
6463 6464 \SpecialChar ~
6464 6465 result.append(b)\SpecialChar ~
6465 6466 \SpecialChar ~
6466 6467 \SpecialChar ~
6467 6468 # see below
6468 6469 \newline
6469 6470
6470 6471 \begin_inset ERT
6471 6472 status Collapsed
6472 6473
6473 6474 \layout Standard
6474 6475
6475 6476 \backslash
6476 6477 hspace*{0mm}
6477 6478 \end_inset
6478 6479
6479 6480 \SpecialChar ~
6480 6481 \SpecialChar ~
6481 6482 ...: ...\SpecialChar ~
6482 6483 \SpecialChar ~
6483 6484 \SpecialChar ~
6484 6485 \SpecialChar ~
6485 6486 \SpecialChar ~
6486 6487 \SpecialChar ~
6487 6488 \SpecialChar ~
6488 6489 \SpecialChar ~
6489 6490 a, b = b, a+b
6490 6491 \newline
6491 6492
6492 6493 \begin_inset ERT
6493 6494 status Collapsed
6494 6495
6495 6496 \layout Standard
6496 6497
6497 6498 \backslash
6498 6499 hspace*{0mm}
6499 6500 \end_inset
6500 6501
6501 6502 \SpecialChar ~
6502 6503 \SpecialChar ~
6503 6504 ...: ...\SpecialChar ~
6504 6505 \SpecialChar ~
6505 6506 \SpecialChar ~
6506 6507 \SpecialChar ~
6507 6508 return result
6508 6509 \newline
6509 6510
6510 6511 \begin_inset ERT
6511 6512 status Collapsed
6512 6513
6513 6514 \layout Standard
6514 6515
6515 6516 \backslash
6516 6517 hspace*{0mm}
6517 6518 \end_inset
6518 6519
6519 6520 \SpecialChar ~
6520 6521 \SpecialChar ~
6521 6522 ...:
6522 6523 \newline
6523 6524 \SpecialChar ~
6524 6525
6525 6526 \newline
6526 6527 In [2]: fib2(10)
6527 6528 \newline
6528 6529 Out[2]: [1, 1, 2, 3, 5, 8]
6529 6530 \layout Standard
6530 6531
6531 6532 Note that as currently written, this extension does
6532 6533 \emph on
6533 6534 not
6534 6535 \emph default
6535 6536 recognize IPython's prompts for pasting.
6536 6537 Those are more complicated, since the user can change them very easily,
6537 6538 they involve numbers and can vary in length.
6538 6539 One could however extract all the relevant information from the IPython
6539 6540 instance and build an appropriate regular expression.
6540 6541 This is left as an exercise for the reader.
6541 6542 \layout Subsection
6542 6543
6543 6544 Input of physical quantities with units
6544 6545 \layout Standard
6545 6546
6546 6547 The module
6547 6548 \family typewriter
6548 6549 PhysicalQInput
6549 6550 \family default
6550 6551 allows a simplified form of input for physical quantities with units.
6551 6552 This file is meant to be used in conjunction with the
6552 6553 \family typewriter
6553 6554 PhysicalQInteractive
6554 6555 \family default
6555 6556 module (in the same directory) and
6556 6557 \family typewriter
6557 6558 Physics.PhysicalQuantities
6558 6559 \family default
6559 6560 from Konrad Hinsen's ScientificPython (
6560 6561 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/hinsen/scientific.html}
6561 6562
6562 6563 \end_inset
6563 6564
6564 6565 ).
6565 6566 \layout Standard
6566 6567
6567 6568 The
6568 6569 \family typewriter
6569 6570 Physics.PhysicalQuantities
6570 6571 \family default
6571 6572 module defines
6572 6573 \family typewriter
6573 6574 PhysicalQuantity
6574 6575 \family default
6575 6576 objects, but these must be declared as instances of a class.
6576 6577 For example, to define
6577 6578 \family typewriter
6578 6579 v
6579 6580 \family default
6580 6581 as a velocity of 3\SpecialChar ~
6581 6582 m/s, normally you would write:
6582 6583 \family typewriter
6583 6584
6584 6585 \newline
6585 6586 In [1]: v = PhysicalQuantity(3,'m/s')
6586 6587 \layout Standard
6587 6588
6588 6589 Using the
6589 6590 \family typewriter
6590 6591 PhysicalQ_Input
6591 6592 \family default
6592 6593 extension this can be input instead as:
6593 6594 \family typewriter
6594 6595
6595 6596 \newline
6596 6597 In [1]: v = 3 m/s
6597 6598 \family default
6598 6599
6599 6600 \newline
6600 6601 which is much more convenient for interactive use (even though it is blatantly
6601 6602 invalid Python syntax).
6602 6603 \layout Standard
6603 6604
6604 6605 The
6605 6606 \family typewriter
6606 6607 physics
6607 6608 \family default
6608 6609 profile supplied with IPython (enabled via
6609 6610 \family typewriter
6610 6611 'ipython -p physics'
6611 6612 \family default
6612 6613 ) uses these extensions, which you can also activate with:
6613 6614 \layout Standard
6614 6615
6615 6616
6616 6617 \family typewriter
6617 6618 from math import * # math MUST be imported BEFORE PhysicalQInteractive
6618 6619 \newline
6619 6620 from IPython.Extensions.PhysicalQInteractive import *
6620 6621 \newline
6621 6622 import IPython.Extensions.PhysicalQInput
6622 6623 \layout Section
6623 6624
6624 6625 IPython as a system shell
6625 6626 \layout Standard
6626 6627
6627 6628 IPython ships with a special profile called
6628 6629 \family typewriter
6629 6630 pysh
6630 6631 \family default
6631 6632 , which you can activate at the command line as
6632 6633 \family typewriter
6633 6634 `ipython -p pysh'
6634 6635 \family default
6635 6636 .
6636 6637 This loads
6637 6638 \family typewriter
6638 6639 InterpreterExec
6639 6640 \family default
6640 6641 , along with some additional facilities and a prompt customized for filesystem
6641 6642 navigation.
6642 6643 \layout Standard
6643 6644
6644 6645 Note that this does
6645 6646 \emph on
6646 6647 not
6647 6648 \emph default
6648 6649 make IPython a full-fledged system shell.
6649 6650 In particular, it has no job control, so if you type Ctrl-Z (under Unix),
6650 6651 you'll suspend pysh itself, not the process you just started.
6651 6652
6652 6653 \layout Standard
6653 6654
6654 6655 What the shell profile allows you to do is to use the convenient and powerful
6655 6656 syntax of Python to do quick scripting at the command line.
6656 6657 Below we describe some of its features.
6657 6658 \layout Subsection
6658 6659
6659 6660 Aliases
6660 6661 \layout Standard
6661 6662
6662 6663 All of your
6663 6664 \family typewriter
6664 6665 $PATH
6665 6666 \family default
6666 6667 has been loaded as IPython aliases, so you should be able to type any normal
6667 6668 system command and have it executed.
6668 6669 See
6669 6670 \family typewriter
6670 6671 %alias?
6671 6672 \family default
6672 6673 and
6673 6674 \family typewriter
6674 6675 %unalias?
6675 6676 \family default
6676 6677 for details on the alias facilities.
6677 6678 See also
6678 6679 \family typewriter
6679 6680 %rehash?
6680 6681 \family default
6681 6682 and
6682 6683 \family typewriter
6683 6684 %rehashx?
6684 6685 \family default
6685 6686 for details on the mechanism used to load
6686 6687 \family typewriter
6687 6688 $PATH
6688 6689 \family default
6689 6690 .
6690 6691 \layout Subsection
6691 6692
6692 6693 Special syntax
6693 6694 \layout Standard
6694 6695
6695 6696 Any lines which begin with
6696 6697 \family typewriter
6697 6698 `~'
6698 6699 \family default
6699 6700 ,
6700 6701 \family typewriter
6701 6702 `/'
6702 6703 \family default
6703 6704 and
6704 6705 \family typewriter
6705 6706 `.'
6706 6707 \family default
6707 6708 will be executed as shell commands instead of as Python code.
6708 6709 The special escapes below are also recognized.
6709 6710
6710 6711 \family typewriter
6711 6712 !cmd
6712 6713 \family default
6713 6714 is valid in single or multi-line input, all others are only valid in single-lin
6714 6715 e input:
6715 6716 \layout Description
6716 6717
6717 6718
6718 6719 \family typewriter
6719 6720 !cmd
6720 6721 \family default
6721 6722 pass `cmd' directly to the shell
6722 6723 \layout Description
6723 6724
6724 6725
6725 6726 \family typewriter
6726 6727 !!cmd
6727 6728 \family default
6728 6729 execute `cmd' and return output as a list (split on `
6729 6730 \backslash
6730 6731 n')
6731 6732 \layout Description
6732 6733
6733 6734
6734 6735 \family typewriter
6735 6736 $var=cmd
6736 6737 \family default
6737 6738 capture output of cmd into var, as a string
6738 6739 \layout Description
6739 6740
6740 6741
6741 6742 \family typewriter
6742 6743 $$var=cmd
6743 6744 \family default
6744 6745 capture output of cmd into var, as a list (split on `
6745 6746 \backslash
6746 6747 n')
6747 6748 \layout Standard
6748 6749
6749 6750 The
6750 6751 \family typewriter
6751 6752 $
6752 6753 \family default
6753 6754 /
6754 6755 \family typewriter
6755 6756 $$
6756 6757 \family default
6757 6758 syntaxes make Python variables from system output, which you can later
6758 6759 use for further scripting.
6759 6760 The converse is also possible: when executing an alias or calling to the
6760 6761 system via
6761 6762 \family typewriter
6762 6763 !
6763 6764 \family default
6764 6765 /
6765 6766 \family typewriter
6766 6767 !!
6767 6768 \family default
6768 6769 , you can expand any python variable or expression by prepending it with
6769 6770
6770 6771 \family typewriter
6771 6772 $
6772 6773 \family default
6773 6774 .
6774 6775 Full details of the allowed syntax can be found in Python's PEP 215.
6775 6776 \layout Standard
6776 6777
6777 6778 A few brief examples will illustrate these (note that the indentation below
6778 6779 may be incorrectly displayed):
6779 6780 \layout Standard
6780 6781
6781 6782
6782 6783 \family typewriter
6783 6784 fperez[~/test]|3> !ls *s.py
6784 6785 \newline
6785 6786 scopes.py strings.py
6786 6787 \layout Standard
6787 6788
6788 6789 ls is an internal alias, so there's no need to use
6789 6790 \family typewriter
6790 6791 !
6791 6792 \family default
6792 6793 :
6793 6794 \layout Standard
6794 6795
6795 6796
6796 6797 \family typewriter
6797 6798 fperez[~/test]|4> ls *s.py
6798 6799 \newline
6799 6800 scopes.py* strings.py
6800 6801 \layout Standard
6801 6802
6802 6803 !!ls will return the output into a Python variable:
6803 6804 \layout Standard
6804 6805
6805 6806
6806 6807 \family typewriter
6807 6808 fperez[~/test]|5> !!ls *s.py
6808 6809 \newline
6809 6810
6810 6811 \begin_inset ERT
6811 6812 status Collapsed
6812 6813
6813 6814 \layout Standard
6814 6815
6815 6816 \backslash
6816 6817 hspace*{0mm}
6817 6818 \end_inset
6818 6819
6819 6820 \SpecialChar ~
6820 6821 \SpecialChar ~
6821 6822 \SpecialChar ~
6822 6823 \SpecialChar ~
6823 6824 \SpecialChar ~
6824 6825 \SpecialChar ~
6825 6826 \SpecialChar ~
6826 6827 \SpecialChar ~
6827 6828 \SpecialChar ~
6828 6829 \SpecialChar ~
6829 6830 \SpecialChar ~
6830 6831 \SpecialChar ~
6831 6832 \SpecialChar ~
6832 6833 \SpecialChar ~
6833 6834 <5> ['scopes.py', 'strings.py']
6834 6835 \newline
6835 6836 fperez[~/test]|6> print _5
6836 6837 \newline
6837 6838 ['scopes.py', 'strings.py']
6838 6839 \layout Standard
6839 6840
6840 6841
6841 6842 \family typewriter
6842 6843 $
6843 6844 \family default
6844 6845 and
6845 6846 \family typewriter
6846 6847 $$
6847 6848 \family default
6848 6849 allow direct capture to named variables:
6849 6850 \layout Standard
6850 6851
6851 6852
6852 6853 \family typewriter
6853 6854 fperez[~/test]|7> $astr = ls *s.py
6854 6855 \newline
6855 6856 fperez[~/test]|8> astr
6856 6857 \newline
6857 6858
6858 6859 \begin_inset ERT
6859 6860 status Collapsed
6860 6861
6861 6862 \layout Standard
6862 6863
6863 6864 \backslash
6864 6865 hspace*{0mm}
6865 6866 \end_inset
6866 6867
6867 6868 \SpecialChar ~
6868 6869 \SpecialChar ~
6869 6870 \SpecialChar ~
6870 6871 \SpecialChar ~
6871 6872 \SpecialChar ~
6872 6873 \SpecialChar ~
6873 6874 \SpecialChar ~
6874 6875 \SpecialChar ~
6875 6876 \SpecialChar ~
6876 6877 \SpecialChar ~
6877 6878 \SpecialChar ~
6878 6879 \SpecialChar ~
6879 6880 \SpecialChar ~
6880 6881 \SpecialChar ~
6881 6882 <8> 'scopes.py
6882 6883 \backslash
6883 6884 nstrings.py'
6884 6885 \layout Standard
6885 6886
6886 6887
6887 6888 \family typewriter
6888 6889 fperez[~/test]|9> $$alist = ls *s.py
6889 6890 \newline
6890 6891 fperez[~/test]|10> alist
6891 6892 \newline
6892 6893
6893 6894 \begin_inset ERT
6894 6895 status Collapsed
6895 6896
6896 6897 \layout Standard
6897 6898
6898 6899 \backslash
6899 6900 hspace*{0mm}
6900 6901 \end_inset
6901 6902
6902 6903 \SpecialChar ~
6903 6904 \SpecialChar ~
6904 6905 \SpecialChar ~
6905 6906 \SpecialChar ~
6906 6907 \SpecialChar ~
6907 6908 \SpecialChar ~
6908 6909 \SpecialChar ~
6909 6910 \SpecialChar ~
6910 6911 \SpecialChar ~
6911 6912 \SpecialChar ~
6912 6913 \SpecialChar ~
6913 6914 \SpecialChar ~
6914 6915 \SpecialChar ~
6915 6916 \SpecialChar ~
6916 6917 <10> ['scopes.py', 'strings.py']
6917 6918 \layout Standard
6918 6919
6919 6920 alist is now a normal python list you can loop over.
6920 6921 Using
6921 6922 \family typewriter
6922 6923 $
6923 6924 \family default
6924 6925 will expand back the python values when alias calls are made:
6925 6926 \layout Standard
6926 6927
6927 6928
6928 6929 \family typewriter
6929 6930 fperez[~/test]|11> for f in alist:
6930 6931 \newline
6931 6932
6932 6933 \begin_inset ERT
6933 6934 status Collapsed
6934 6935
6935 6936 \layout Standard
6936 6937
6937 6938 \backslash
6938 6939 hspace*{0mm}
6939 6940 \end_inset
6940 6941
6941 6942 \SpecialChar ~
6942 6943 \SpecialChar ~
6943 6944 \SpecialChar ~
6944 6945 \SpecialChar ~
6945 6946 \SpecialChar ~
6946 6947 \SpecialChar ~
6947 6948 \SpecialChar ~
6948 6949 \SpecialChar ~
6949 6950 \SpecialChar ~
6950 6951 \SpecialChar ~
6951 6952 \SpecialChar ~
6952 6953 \SpecialChar ~
6953 6954 \SpecialChar ~
6954 6955 \SpecialChar ~
6955 6956 |..> \SpecialChar ~
6956 6957 \SpecialChar ~
6957 6958 \SpecialChar ~
6958 6959 \SpecialChar ~
6959 6960 print 'file',f,
6960 6961 \newline
6961 6962
6962 6963 \begin_inset ERT
6963 6964 status Collapsed
6964 6965
6965 6966 \layout Standard
6966 6967
6967 6968 \backslash
6968 6969 hspace*{0mm}
6969 6970 \end_inset
6970 6971
6971 6972 \SpecialChar ~
6972 6973 \SpecialChar ~
6973 6974 \SpecialChar ~
6974 6975 \SpecialChar ~
6975 6976 \SpecialChar ~
6976 6977 \SpecialChar ~
6977 6978 \SpecialChar ~
6978 6979 \SpecialChar ~
6979 6980 \SpecialChar ~
6980 6981 \SpecialChar ~
6981 6982 \SpecialChar ~
6982 6983 \SpecialChar ~
6983 6984 \SpecialChar ~
6984 6985 \SpecialChar ~
6985 6986 |..> \SpecialChar ~
6986 6987 \SpecialChar ~
6987 6988 \SpecialChar ~
6988 6989 \SpecialChar ~
6989 6990 wc -l $f
6990 6991 \newline
6991 6992
6992 6993 \begin_inset ERT
6993 6994 status Collapsed
6994 6995
6995 6996 \layout Standard
6996 6997
6997 6998 \backslash
6998 6999 hspace*{0mm}
6999 7000 \end_inset
7000 7001
7001 7002 \SpecialChar ~
7002 7003 \SpecialChar ~
7003 7004 \SpecialChar ~
7004 7005 \SpecialChar ~
7005 7006 \SpecialChar ~
7006 7007 \SpecialChar ~
7007 7008 \SpecialChar ~
7008 7009 \SpecialChar ~
7009 7010 \SpecialChar ~
7010 7011 \SpecialChar ~
7011 7012 \SpecialChar ~
7012 7013 \SpecialChar ~
7013 7014 \SpecialChar ~
7014 7015 \SpecialChar ~
7015 7016 |..>
7016 7017 \newline
7017 7018 file scopes.py 13 scopes.py
7018 7019 \newline
7019 7020 file strings.py 4 strings.py
7020 7021 \layout Standard
7021 7022
7022 7023 Note that you may need to protect your variables with braces if you want
7023 7024 to append strings to their names.
7024 7025 To copy all files in alist to
7025 7026 \family typewriter
7026 7027 .bak
7027 7028 \family default
7028 7029 extensions, you must use:
7029 7030 \layout Standard
7030 7031
7031 7032
7032 7033 \family typewriter
7033 7034 fperez[~/test]|12> for f in alist:
7034 7035 \newline
7035 7036
7036 7037 \begin_inset ERT
7037 7038 status Collapsed
7038 7039
7039 7040 \layout Standard
7040 7041
7041 7042 \backslash
7042 7043 hspace*{0mm}
7043 7044 \end_inset
7044 7045
7045 7046 \SpecialChar ~
7046 7047 \SpecialChar ~
7047 7048 \SpecialChar ~
7048 7049 \SpecialChar ~
7049 7050 \SpecialChar ~
7050 7051 \SpecialChar ~
7051 7052 \SpecialChar ~
7052 7053 \SpecialChar ~
7053 7054 \SpecialChar ~
7054 7055 \SpecialChar ~
7055 7056 \SpecialChar ~
7056 7057 \SpecialChar ~
7057 7058 \SpecialChar ~
7058 7059 \SpecialChar ~
7059 7060 |..> \SpecialChar ~
7060 7061 \SpecialChar ~
7061 7062 \SpecialChar ~
7062 7063 \SpecialChar ~
7063 7064 cp $f ${f}.bak
7064 7065 \layout Standard
7065 7066
7066 7067 If you try using
7067 7068 \family typewriter
7068 7069 $f.bak
7069 7070 \family default
7070 7071 , you'll get an AttributeError exception saying that your string object
7071 7072 doesn't have a
7072 7073 \family typewriter
7073 7074 .bak
7074 7075 \family default
7075 7076 attribute.
7076 7077 This is because the
7077 7078 \family typewriter
7078 7079 $
7079 7080 \family default
7080 7081 expansion mechanism allows you to expand full Python expressions:
7081 7082 \layout Standard
7082 7083
7083 7084
7084 7085 \family typewriter
7085 7086 fperez[~/test]|13> echo "sys.platform is: $sys.platform"
7086 7087 \newline
7087 7088 sys.platform is: linux2
7088 7089 \layout Standard
7089 7090
7090 7091 IPython's input history handling is still active, which allows you to rerun
7091 7092 a single block of multi-line input by simply using exec:
7092 7093 \newline
7093 7094
7094 7095 \family typewriter
7095 7096 fperez[~/test]|14> $$alist = ls *.eps
7096 7097 \newline
7097 7098 fperez[~/test]|15> exec _i11
7098 7099 \newline
7099 7100 file image2.eps 921 image2.eps
7100 7101 \newline
7101 7102 file image.eps 921 image.eps
7102 7103 \layout Standard
7103 7104
7104 7105 While these are new special-case syntaxes, they are designed to allow very
7105 7106 efficient use of the shell with minimal typing.
7106 7107 At an interactive shell prompt, conciseness of expression wins over readability.
7107 7108 \layout Subsection
7108 7109
7109 7110 Useful functions and modules
7110 7111 \layout Standard
7111 7112
7112 7113 The os, sys and shutil modules from the Python standard library are automaticall
7113 7114 y loaded.
7114 7115 Some additional functions, useful for shell usage, are listed below.
7115 7116 You can request more help about them with `
7116 7117 \family typewriter
7117 7118 ?
7118 7119 \family default
7119 7120 '.
7120 7121 \layout Description
7121 7122
7122 7123
7123 7124 \family typewriter
7124 7125 shell
7125 7126 \family default
7126 7127 - execute a command in the underlying system shell
7127 7128 \layout Description
7128 7129
7129 7130
7130 7131 \family typewriter
7131 7132 system
7132 7133 \family default
7133 7134 - like
7134 7135 \family typewriter
7135 7136 shell()
7136 7137 \family default
7137 7138 , but return the exit status of the command
7138 7139 \layout Description
7139 7140
7140 7141
7141 7142 \family typewriter
7142 7143 sout
7143 7144 \family default
7144 7145 - capture the output of a command as a string
7145 7146 \layout Description
7146 7147
7147 7148
7148 7149 \family typewriter
7149 7150 lout
7150 7151 \family default
7151 7152 - capture the output of a command as a list (split on `
7152 7153 \backslash
7153 7154 n')
7154 7155 \layout Description
7155 7156
7156 7157
7157 7158 \family typewriter
7158 7159 getoutputerror
7159 7160 \family default
7160 7161 - capture (output,error) of a shell commandss
7161 7162 \layout Standard
7162 7163
7163 7164
7164 7165 \family typewriter
7165 7166 sout
7166 7167 \family default
7167 7168 /
7168 7169 \family typewriter
7169 7170 lout
7170 7171 \family default
7171 7172 are the functional equivalents of
7172 7173 \family typewriter
7173 7174 $
7174 7175 \family default
7175 7176 /
7176 7177 \family typewriter
7177 7178 $$
7178 7179 \family default
7179 7180 .
7180 7181 They are provided to allow you to capture system output in the middle of
7181 7182 true python code, function definitions, etc (where
7182 7183 \family typewriter
7183 7184 $
7184 7185 \family default
7185 7186 and
7186 7187 \family typewriter
7187 7188 $$
7188 7189 \family default
7189 7190 are invalid).
7190 7191 \layout Subsection
7191 7192
7192 7193 Directory management
7193 7194 \layout Standard
7194 7195
7195 7196 Since each command passed by pysh to the underlying system is executed in
7196 7197 a subshell which exits immediately, you can NOT use !cd to navigate the
7197 7198 filesystem.
7198 7199 \layout Standard
7199 7200
7200 7201 Pysh provides its own builtin
7201 7202 \family typewriter
7202 7203 `%cd
7203 7204 \family default
7204 7205 ' magic command to move in the filesystem (the
7205 7206 \family typewriter
7206 7207 %
7207 7208 \family default
7208 7209 is not required with automagic on).
7209 7210 It also maintains a list of visited directories (use
7210 7211 \family typewriter
7211 7212 %dhist
7212 7213 \family default
7213 7214 to see it) and allows direct switching to any of them.
7214 7215 Type
7215 7216 \family typewriter
7216 7217 `cd?
7217 7218 \family default
7218 7219 ' for more details.
7219 7220 \layout Standard
7220 7221
7221 7222
7222 7223 \family typewriter
7223 7224 %pushd
7224 7225 \family default
7225 7226 ,
7226 7227 \family typewriter
7227 7228 %popd
7228 7229 \family default
7229 7230 and
7230 7231 \family typewriter
7231 7232 %dirs
7232 7233 \family default
7233 7234 are provided for directory stack handling.
7234 7235 \layout Subsection
7235 7236
7236 7237 Prompt customization
7237 7238 \layout Standard
7238 7239
7239 7240 The supplied
7240 7241 \family typewriter
7241 7242 ipythonrc-pysh
7242 7243 \family default
7243 7244 profile comes with an example of a very colored and detailed prompt, mainly
7244 7245 to serve as an illustration.
7245 7246 The valid escape sequences, besides color names, are:
7246 7247 \layout Description
7247 7248
7248 7249
7249 7250 \backslash
7250 7251 # - Prompt number.
7251 7252 \layout Description
7252 7253
7253 7254
7254 7255 \backslash
7255 7256 D - Dots, as many as there are digits in
7256 7257 \backslash
7257 7258 # (so they align).
7258 7259 \layout Description
7259 7260
7260 7261
7261 7262 \backslash
7262 7263 w - Current working directory (cwd).
7263 7264 \layout Description
7264 7265
7265 7266
7266 7267 \backslash
7267 7268 W - Basename of current working directory.
7268 7269 \layout Description
7269 7270
7270 7271
7271 7272 \backslash
7272 7273 X
7273 7274 \emph on
7274 7275 N
7275 7276 \emph default
7276 7277 - Where
7277 7278 \emph on
7278 7279 N
7279 7280 \emph default
7280 7281 =0..5.
7281 7282 N terms of the cwd, with $HOME written as ~.
7282 7283 \layout Description
7283 7284
7284 7285
7285 7286 \backslash
7286 7287 Y
7287 7288 \emph on
7288 7289 N
7289 7290 \emph default
7290 7291 - Where
7291 7292 \emph on
7292 7293 N
7293 7294 \emph default
7294 7295 =0..5.
7295 7296 Like X
7296 7297 \emph on
7297 7298 N
7298 7299 \emph default
7299 7300 , but if ~ is term
7300 7301 \emph on
7301 7302 N
7302 7303 \emph default
7303 7304 +1 it's also shown.
7304 7305 \layout Description
7305 7306
7306 7307
7307 7308 \backslash
7308 7309 u - Username.
7309 7310 \layout Description
7310 7311
7311 7312
7312 7313 \backslash
7313 7314 H - Full hostname.
7314 7315 \layout Description
7315 7316
7316 7317
7317 7318 \backslash
7318 7319 h - Hostname up to first '.'
7319 7320 \layout Description
7320 7321
7321 7322
7322 7323 \backslash
7323 7324 $ - Root symbol ($ or #).
7324 7325
7325 7326 \layout Description
7326 7327
7327 7328
7328 7329 \backslash
7329 7330 t - Current time, in H:M:S format.
7330 7331 \layout Description
7331 7332
7332 7333
7333 7334 \backslash
7334 7335 v - IPython release version.
7335 7336
7336 7337 \layout Description
7337 7338
7338 7339
7339 7340 \backslash
7340 7341 n - Newline.
7341 7342
7342 7343 \layout Description
7343 7344
7344 7345
7345 7346 \backslash
7346 7347 r - Carriage return.
7347 7348
7348 7349 \layout Description
7349 7350
7350 7351
7351 7352 \backslash
7352 7353
7353 7354 \backslash
7354 7355 - An explicitly escaped '
7355 7356 \backslash
7356 7357 '.
7357 7358 \layout Standard
7358 7359
7359 7360 You can configure your prompt colors using any ANSI color escape.
7360 7361 Each color escape sets the color for any subsequent text, until another
7361 7362 escape comes in and changes things.
7362 7363 The valid color escapes are:
7363 7364 \layout Description
7364 7365
7365 7366
7366 7367 \backslash
7367 7368 C_Black
7368 7369 \layout Description
7369 7370
7370 7371
7371 7372 \backslash
7372 7373 C_Blue
7373 7374 \layout Description
7374 7375
7375 7376
7376 7377 \backslash
7377 7378 C_Brown
7378 7379 \layout Description
7379 7380
7380 7381
7381 7382 \backslash
7382 7383 C_Cyan
7383 7384 \layout Description
7384 7385
7385 7386
7386 7387 \backslash
7387 7388 C_DarkGray
7388 7389 \layout Description
7389 7390
7390 7391
7391 7392 \backslash
7392 7393 C_Green
7393 7394 \layout Description
7394 7395
7395 7396
7396 7397 \backslash
7397 7398 C_LightBlue
7398 7399 \layout Description
7399 7400
7400 7401
7401 7402 \backslash
7402 7403 C_LightCyan
7403 7404 \layout Description
7404 7405
7405 7406
7406 7407 \backslash
7407 7408 C_LightGray
7408 7409 \layout Description
7409 7410
7410 7411
7411 7412 \backslash
7412 7413 C_LightGreen
7413 7414 \layout Description
7414 7415
7415 7416
7416 7417 \backslash
7417 7418 C_LightPurple
7418 7419 \layout Description
7419 7420
7420 7421
7421 7422 \backslash
7422 7423 C_LightRed
7423 7424 \layout Description
7424 7425
7425 7426
7426 7427 \backslash
7427 7428 C_Purple
7428 7429 \layout Description
7429 7430
7430 7431
7431 7432 \backslash
7432 7433 C_Red
7433 7434 \layout Description
7434 7435
7435 7436
7436 7437 \backslash
7437 7438 C_White
7438 7439 \layout Description
7439 7440
7440 7441
7441 7442 \backslash
7442 7443 C_Yellow
7443 7444 \layout Description
7444 7445
7445 7446
7446 7447 \backslash
7447 7448 C_Normal Stop coloring, defaults to your terminal settings.
7448 7449 \layout Section
7449 7450
7450 7451
7451 7452 \begin_inset LatexCommand \label{sec:Threading-support}
7452 7453
7453 7454 \end_inset
7454 7455
7455 7456 Threading support
7456 7457 \layout Standard
7457 7458
7458 7459
7459 7460 \series bold
7460 7461 WARNING:
7461 7462 \series default
7462 7463 The threading support is still somewhat experimental, and it has only seen
7463 7464 reasonable testing under Linux.
7464 7465 Threaded code is particularly tricky to debug, and it tends to show extremely
7465 7466 platform-dependent behavior.
7466 7467 Since I only have access to Linux machines, I will have to rely on user's
7467 7468 experiences and assistance for this area of IPython to improve under other
7468 7469 platforms.
7469 7470 \layout Standard
7470 7471
7471 7472 IPython, via the
7472 7473 \family typewriter
7473 7474 -gthread
7474 7475 \family default
7475 7476 and
7476 7477 \family typewriter
7477 7478 -wthread
7478 7479 \family default
7479 7480 options (described in Sec.\SpecialChar ~
7480 7481
7481 7482 \begin_inset LatexCommand \ref{sec:threading-opts}
7482 7483
7483 7484 \end_inset
7484 7485
7485 7486 ), can run in multithreaded mode to support pyGTK and WXPython applications
7486 7487 respectively.
7487 7488 Both of these GUI toolkits need to control the python main loop of execution,
7488 7489 so under a normal Python interpreter, starting a pyGTK (or WXPython) applicatio
7489 7490 n will immediately freeze the shell.
7490 7491
7491 7492 \layout Standard
7492 7493
7493 7494 IPython, with one of these options (you can only use one at a time), separates
7494 7495 the graphical loop and IPython's code execution run into different threads.
7495 7496 This allows you to test interactively (with
7496 7497 \family typewriter
7497 7498 %run
7498 7499 \family default
7499 7500 , for example) your GUI code without blocking.
7500 7501 \layout Subsection
7501 7502
7502 7503 Tk issues
7503 7504 \layout Standard
7504 7505
7505 7506 As indicated in Sec.\SpecialChar ~
7506 7507
7507 7508 \begin_inset LatexCommand \ref{sec:threading-opts}
7508 7509
7509 7510 \end_inset
7510 7511
7511 7512 , a special
7512 7513 \family typewriter
7513 7514 -tk
7514 7515 \family default
7515 7516 option is provided to try and allow Tk graphical applications to coexist
7516 7517 interactively with WX or GTK ones.
7517 7518 Whether this works at all, however, is very platform and configuration
7518 7519 dependent.
7519 7520 Please experiment with simple test cases before committing to using this
7520 7521 combination of Tk and WX/GTK threading in a production environment.
7521 7522 \layout Subsection
7522 7523
7523 7524 Signals and Threads
7524 7525 \layout Standard
7525 7526
7526 7527 When any of the thread systems (WX or GTK) are active, either directly or
7527 7528 via
7528 7529 \family typewriter
7529 7530 -pylab
7530 7531 \family default
7531 7532 with a threaded backend, it is impossible to interrupt long-running Python
7532 7533 code via
7533 7534 \family typewriter
7534 7535 Ctrl-C
7535 7536 \family default
7536 7537 .
7537 7538 IPython can not pass the KeyboardInterrupt exception (or the underlying
7538 7539
7539 7540 \family typewriter
7540 7541 SIGINT
7541 7542 \family default
7542 7543 ) across threads, so any long-running process started from IPython will
7543 7544 run to completion, or will have to be killed via an external (OS-based)
7544 7545 mechanism.
7545 7546 \layout Standard
7546 7547
7547 7548 To the best of my knowledge, this limitation is imposed by the Python interprete
7548 7549 r itself, and it comes from the difficulty of writing portable signal/threaded
7549 7550 code.
7550 7551 If any user is an expert on this topic and can suggest a better solution,
7551 7552 I would love to hear about it.
7552 7553 In the IPython sources, look at the
7553 7554 \family typewriter
7554 7555 Shell.py
7555 7556 \family default
7556 7557 module, and in particular at the
7557 7558 \family typewriter
7558 7559 runcode()
7559 7560 \family default
7560 7561 method.
7561 7562
7562 7563 \layout Subsection
7563 7564
7564 7565 I/O pitfalls
7565 7566 \layout Standard
7566 7567
7567 7568 Be mindful that the Python interpreter switches between threads every
7568 7569 \begin_inset Formula $N$
7569 7570 \end_inset
7570 7571
7571 7572 bytecodes, where the default value as of Python\SpecialChar ~
7572 7573 2.3 is
7573 7574 \begin_inset Formula $N=100.$
7574 7575 \end_inset
7575 7576
7576 7577 This value can be read by using the
7577 7578 \family typewriter
7578 7579 sys.getcheckinterval()
7579 7580 \family default
7580 7581 function, and it can be reset via
7581 7582 \family typewriter
7582 7583 sys.setcheckinterval(
7583 7584 \emph on
7584 7585 N
7585 7586 \emph default
7586 7587 )
7587 7588 \family default
7588 7589 .
7589 7590 This switching of threads can cause subtly confusing effects if one of
7590 7591 your threads is doing file I/O.
7591 7592 In text mode, most systems only flush file buffers when they encounter
7592 7593 a
7593 7594 \family typewriter
7594 7595 `
7595 7596 \backslash
7596 7597 n'
7597 7598 \family default
7598 7599 .
7599 7600 An instruction as simple as
7600 7601 \family typewriter
7601 7602
7602 7603 \newline
7603 7604 \SpecialChar ~
7604 7605 \SpecialChar ~
7605 7606 print >> filehandle,
7606 7607 \begin_inset Quotes eld
7607 7608 \end_inset
7608 7609
7609 7610 hello world
7610 7611 \begin_inset Quotes erd
7611 7612 \end_inset
7612 7613
7613 7614
7614 7615 \family default
7615 7616
7616 7617 \newline
7617 7618 actually consists of several bytecodes, so it is possible that the newline
7618 7619 does not reach your file before the next thread switch.
7619 7620 Similarly, if you are writing to a file in binary mode, the file won't
7620 7621 be flushed until the buffer fills, and your other thread may see apparently
7621 7622 truncated files.
7622 7623
7623 7624 \layout Standard
7624 7625
7625 7626 For this reason, if you are using IPython's thread support and have (for
7626 7627 example) a GUI application which will read data generated by files written
7627 7628 to from the IPython thread, the safest approach is to open all of your
7628 7629 files in unbuffered mode (the third argument to the
7629 7630 \family typewriter
7630 7631 file/open
7631 7632 \family default
7632 7633 function is the buffering value):
7633 7634 \newline
7634 7635
7635 7636 \family typewriter
7636 7637 \SpecialChar ~
7637 7638 \SpecialChar ~
7638 7639 filehandle = open(filename,mode,0)
7639 7640 \layout Standard
7640 7641
7641 7642 This is obviously a brute force way of avoiding race conditions with the
7642 7643 file buffering.
7643 7644 If you want to do it cleanly, and you have a resource which is being shared
7644 7645 by the interactive IPython loop and your GUI thread, you should really
7645 7646 handle it with thread locking and syncrhonization properties.
7646 7647 The Python documentation discusses these.
7647 7648 \layout Section
7648 7649
7649 7650
7650 7651 \begin_inset LatexCommand \label{sec:matplotlib-support}
7651 7652
7652 7653 \end_inset
7653 7654
7654 7655 Plotting with
7655 7656 \family typewriter
7656 7657 matplotlib
7657 7658 \family default
7658 7659
7659 7660 \layout Standard
7660 7661
7661 7662 The matplotlib library (
7662 7663 \begin_inset LatexCommand \htmlurl[http://matplotlib.sourceforge.net]{http://matplotlib.sourceforge.net}
7663 7664
7664 7665 \end_inset
7665 7666
7666 7667 ) provides high quality 2D plotting for Python.
7667 7668 Matplotlib can produce plots on screen using a variety of GUI toolkits,
7668 7669 including Tk, GTK and WXPython.
7669 7670 It also provides a number of commands useful for scientific computing,
7670 7671 all with a syntax compatible with that of the popular Matlab program.
7671 7672 \layout Standard
7672 7673
7673 7674 IPython accepts the special option
7674 7675 \family typewriter
7675 7676 -pylab
7676 7677 \family default
7677 7678 (Sec.\SpecialChar ~
7678 7679
7679 7680 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
7680 7681
7681 7682 \end_inset
7682 7683
7683 7684 ).
7684 7685 This configures it to support matplotlib, honoring the settings in the
7685 7686
7686 7687 \family typewriter
7687 7688 .matplotlibrc
7688 7689 \family default
7689 7690 file.
7690 7691 IPython will detect the user's choice of matplotlib GUI backend, and automatica
7691 7692 lly select the proper threading model to prevent blocking.
7692 7693 It also sets matplotlib in interactive mode and modifies
7693 7694 \family typewriter
7694 7695 %run
7695 7696 \family default
7696 7697 slightly, so that any matplotlib-based script can be executed using
7697 7698 \family typewriter
7698 7699 %run
7699 7700 \family default
7700 7701 and the final
7701 7702 \family typewriter
7702 7703 show()
7703 7704 \family default
7704 7705 command does not block the interactive shell.
7705 7706 \layout Standard
7706 7707
7707 7708 The
7708 7709 \family typewriter
7709 7710 -pylab
7710 7711 \family default
7711 7712 option must be given first in order for IPython to configure its threading
7712 7713 mode.
7713 7714 However, you can still issue other options afterwards.
7714 7715 This allows you to have a matplotlib-based environment customized with
7715 7716 additional modules using the standard IPython profile mechanism (Sec.\SpecialChar ~
7716 7717
7717 7718 \begin_inset LatexCommand \ref{sec:profiles}
7718 7719
7719 7720 \end_inset
7720 7721
7721 7722 ): ``
7722 7723 \family typewriter
7723 7724 ipython -pylab -p myprofile
7724 7725 \family default
7725 7726 '' will load the profile defined in
7726 7727 \family typewriter
7727 7728 ipythonrc-myprofile
7728 7729 \family default
7729 7730 after configuring matplotlib.
7730 7731 \layout Section
7731 7732
7732 7733
7733 7734 \begin_inset LatexCommand \label{sec:Gnuplot}
7734 7735
7735 7736 \end_inset
7736 7737
7737 7738 Plotting with
7738 7739 \family typewriter
7739 7740 Gnuplot
7740 7741 \layout Standard
7741 7742
7742 7743 Through the magic extension system described in sec.
7743 7744
7744 7745 \begin_inset LatexCommand \ref{sec:magic}
7745 7746
7746 7747 \end_inset
7747 7748
7748 7749 , IPython incorporates a mechanism for conveniently interfacing with the
7749 7750 Gnuplot system (
7750 7751 \begin_inset LatexCommand \htmlurl{http://www.gnuplot.info}
7751 7752
7752 7753 \end_inset
7753 7754
7754 7755 ).
7755 7756 Gnuplot is a very complete 2D and 3D plotting package available for many
7756 7757 operating systems and commonly included in modern Linux distributions.
7757 7758
7758 7759 \layout Standard
7759 7760
7760 7761 Besides having Gnuplot installed, this functionality requires the
7761 7762 \family typewriter
7762 7763 Gnuplot.py
7763 7764 \family default
7764 7765 module for interfacing python with Gnuplot.
7765 7766 It can be downloaded from:
7766 7767 \begin_inset LatexCommand \htmlurl{http://gnuplot-py.sourceforge.net}
7767 7768
7768 7769 \end_inset
7769 7770
7770 7771 .
7771 7772 \layout Subsection
7772 7773
7773 7774 Proper Gnuplot configuration
7774 7775 \layout Standard
7775 7776
7776 7777 As of version 4.0, Gnuplot has excellent mouse and interactive keyboard support.
7777 7778 However, as of
7778 7779 \family typewriter
7779 7780 Gnuplot.py
7780 7781 \family default
7781 7782 version 1.7, a new option was added to communicate between Python and Gnuplot
7782 7783 via FIFOs (pipes).
7783 7784 This mechanism, while fast, also breaks the mouse system.
7784 7785 You must therefore set the variable
7785 7786 \family typewriter
7786 7787 prefer_fifo_data
7787 7788 \family default
7788 7789 to
7789 7790 \family typewriter
7790 7791 0
7791 7792 \family default
7792 7793 in file
7793 7794 \family typewriter
7794 7795 gp_unix.py
7795 7796 \family default
7796 7797 if you wish to keep the interactive mouse and keyboard features working
7797 7798 properly (
7798 7799 \family typewriter
7799 7800 prefer_inline_data
7800 7801 \family default
7801 7802 also must be
7802 7803 \family typewriter
7803 7804 0
7804 7805 \family default
7805 7806 , but this is the default so unless you've changed it manually you should
7806 7807 be fine).
7807 7808 \layout Standard
7808 7809
7809 7810 'Out of the box', Gnuplot is configured with a rather poor set of size,
7810 7811 color and linewidth choices which make the graphs fairly hard to read on
7811 7812 modern high-resolution displays (although they work fine on old 640x480
7812 7813 ones).
7813 7814 Below is a section of my
7814 7815 \family typewriter
7815 7816 .Xdefaults
7816 7817 \family default
7817 7818 file which I use for having a more convenient Gnuplot setup.
7818 7819 Remember to load it by running
7819 7820 \family typewriter
7820 7821 `xrdb .Xdefaults`
7821 7822 \family default
7822 7823 :
7823 7824 \layout Standard
7824 7825
7825 7826
7826 7827 \family typewriter
7827 7828 !******************************************************************
7828 7829 \newline
7829 7830 ! gnuplot options
7830 7831 \newline
7831 7832 ! modify this for a convenient window size
7832 7833 \newline
7833 7834 gnuplot*geometry: 780x580
7834 7835 \layout Standard
7835 7836
7836 7837
7837 7838 \family typewriter
7838 7839 ! on-screen font (not for PostScript)
7839 7840 \newline
7840 7841 gnuplot*font: -misc-fixed-bold-r-normal--15-120-100-100-c-90-iso8859-1
7841 7842 \layout Standard
7842 7843
7843 7844
7844 7845 \family typewriter
7845 7846 ! color options
7846 7847 \newline
7847 7848 gnuplot*background: black
7848 7849 \newline
7849 7850 gnuplot*textColor: white
7850 7851 \newline
7851 7852 gnuplot*borderColor: white
7852 7853 \newline
7853 7854 gnuplot*axisColor: white
7854 7855 \newline
7855 7856 gnuplot*line1Color: red
7856 7857 \newline
7857 7858 gnuplot*line2Color: green
7858 7859 \newline
7859 7860 gnuplot*line3Color: blue
7860 7861 \newline
7861 7862 gnuplot*line4Color: magenta
7862 7863 \newline
7863 7864 gnuplot*line5Color: cyan
7864 7865 \newline
7865 7866 gnuplot*line6Color: sienna
7866 7867 \newline
7867 7868 gnuplot*line7Color: orange
7868 7869 \newline
7869 7870 gnuplot*line8Color: coral
7870 7871 \layout Standard
7871 7872
7872 7873
7873 7874 \family typewriter
7874 7875 ! multiplicative factor for point styles
7875 7876 \newline
7876 7877 gnuplot*pointsize: 2
7877 7878 \layout Standard
7878 7879
7879 7880
7880 7881 \family typewriter
7881 7882 ! line width options (in pixels)
7882 7883 \newline
7883 7884 gnuplot*borderWidth: 2
7884 7885 \newline
7885 7886 gnuplot*axisWidth: 2
7886 7887 \newline
7887 7888 gnuplot*line1Width: 2
7888 7889 \newline
7889 7890 gnuplot*line2Width: 2
7890 7891 \newline
7891 7892 gnuplot*line3Width: 2
7892 7893 \newline
7893 7894 gnuplot*line4Width: 2
7894 7895 \newline
7895 7896 gnuplot*line5Width: 2
7896 7897 \newline
7897 7898 gnuplot*line6Width: 2
7898 7899 \newline
7899 7900 gnuplot*line7Width: 2
7900 7901 \newline
7901 7902 gnuplot*line8Width: 2
7902 7903 \layout Subsection
7903 7904
7904 7905 The
7905 7906 \family typewriter
7906 7907 IPython.GnuplotRuntime
7907 7908 \family default
7908 7909 module
7909 7910 \layout Standard
7910 7911
7911 7912 IPython includes a module called
7912 7913 \family typewriter
7913 7914 Gnuplot2.py
7914 7915 \family default
7915 7916 which extends and improves the default
7916 7917 \family typewriter
7917 7918 Gnuplot
7918 7919 \family default
7919 7920 .
7920 7921 \family typewriter
7921 7922 py
7922 7923 \family default
7923 7924 (which it still relies upon).
7924 7925 For example, the new
7925 7926 \family typewriter
7926 7927 plot
7927 7928 \family default
7928 7929 function adds several improvements to the original making it more convenient
7929 7930 for interactive use, and
7930 7931 \family typewriter
7931 7932 hardcopy
7932 7933 \family default
7933 7934 fixes a bug in the original which under some circumstances blocks the creation
7934 7935 of PostScript output.
7935 7936 \layout Standard
7936 7937
7937 7938 For scripting use,
7938 7939 \family typewriter
7939 7940 GnuplotRuntime.py
7940 7941 \family default
7941 7942 is provided, which wraps
7942 7943 \family typewriter
7943 7944 Gnuplot2.py
7944 7945 \family default
7945 7946 and creates a series of global aliases.
7946 7947 These make it easy to control Gnuplot plotting jobs through the Python
7947 7948 language.
7948 7949 \layout Standard
7949 7950
7950 7951 Below is some example code which illustrates how to configure Gnuplot inside
7951 7952 your own programs but have it available for further interactive use through
7952 7953 an embedded IPython instance.
7953 7954 Simply run this file at a system prompt.
7954 7955 This file is provided as
7955 7956 \family typewriter
7956 7957 example-gnuplot.py
7957 7958 \family default
7958 7959 in the examples directory:
7959 7960 \layout Standard
7960 7961
7961 7962
7962 7963 \begin_inset Include \verbatiminput{examples/example-gnuplot.py}
7963 7964 preview false
7964 7965
7965 7966 \end_inset
7966 7967
7967 7968
7968 7969 \layout Subsection
7969 7970
7970 7971 The
7971 7972 \family typewriter
7972 7973 numeric
7973 7974 \family default
7974 7975 profile: a scientific computing environment
7975 7976 \layout Standard
7976 7977
7977 7978 The
7978 7979 \family typewriter
7979 7980 numeric
7980 7981 \family default
7981 7982 IPython profile, which you can activate with
7982 7983 \family typewriter
7983 7984 `ipython -p numeric
7984 7985 \family default
7985 7986 ' will automatically load the IPython Gnuplot extensions (plus Numeric and
7986 7987 other useful things for numerical computing), contained in the
7987 7988 \family typewriter
7988 7989 IPython.GnuplotInteractive
7989 7990 \family default
7990 7991 module.
7991 7992 This will create the globals
7992 7993 \family typewriter
7993 7994 Gnuplot
7994 7995 \family default
7995 7996 (an alias to the improved Gnuplot2 module),
7996 7997 \family typewriter
7997 7998 gp
7998 7999 \family default
7999 8000 (a Gnuplot active instance), the new magic commands
8000 8001 \family typewriter
8001 8002 %gpc
8002 8003 \family default
8003 8004 and
8004 8005 \family typewriter
8005 8006 %gp_set_instance
8006 8007 \family default
8007 8008 and several other convenient globals.
8008 8009 Type
8009 8010 \family typewriter
8010 8011 gphelp()
8011 8012 \family default
8012 8013 for further details.
8013 8014 \layout Standard
8014 8015
8015 8016 This should turn IPython into a convenient environment for numerical computing,
8016 8017 with all the functions in the NumPy library and the Gnuplot facilities
8017 8018 for plotting.
8018 8019 Further improvements can be obtained by loading the SciPy libraries for
8019 8020 scientific computing, available at
8020 8021 \begin_inset LatexCommand \htmlurl{http://scipy.org}
8021 8022
8022 8023 \end_inset
8023 8024
8024 8025 .
8025 8026 \layout Standard
8026 8027
8027 8028 If you are in the middle of a working session with numerical objects and
8028 8029 need to plot them but you didn't start the
8029 8030 \family typewriter
8030 8031 numeric
8031 8032 \family default
8032 8033 profile, you can load these extensions at any time by typing
8033 8034 \newline
8034 8035
8035 8036 \family typewriter
8036 8037 from IPython.GnuplotInteractive import *
8037 8038 \newline
8038 8039
8039 8040 \family default
8040 8041 at the IPython prompt.
8041 8042 This will allow you to keep your objects intact and start using Gnuplot
8042 8043 to view them.
8043 8044 \layout Section
8044 8045
8045 8046 Reporting bugs
8046 8047 \layout Subsection*
8047 8048
8048 8049 Automatic crash reports
8049 8050 \layout Standard
8050 8051
8051 8052 Ideally, IPython itself shouldn't crash.
8052 8053 It will catch exceptions produced by you, but bugs in its internals will
8053 8054 still crash it.
8054 8055 \layout Standard
8055 8056
8056 8057 In such a situation, IPython will leave a file named
8057 8058 \family typewriter
8058 8059 IPython_crash_report.txt
8059 8060 \family default
8060 8061 in your IPYTHONDIR directory (that way if crashes happen several times
8061 8062 it won't litter many directories, the post-mortem file is always located
8062 8063 in the same place and new occurrences just overwrite the previous one).
8063 8064 If you can mail this file to the developers (see sec.
8064 8065
8065 8066 \begin_inset LatexCommand \ref{sec:credits}
8066 8067
8067 8068 \end_inset
8068 8069
8069 8070 for names and addresses), it will help us
8070 8071 \emph on
8071 8072 a lot
8072 8073 \emph default
8073 8074 in understanding the cause of the problem and fixing it sooner.
8074 8075 \layout Subsection*
8075 8076
8076 8077 The bug tracker
8077 8078 \layout Standard
8078 8079
8079 8080 IPython also has an online bug-tracker, located at
8080 8081 \begin_inset LatexCommand \htmlurl{http://www.scipy.net/roundup/ipython}
8081 8082
8082 8083 \end_inset
8083 8084
8084 8085 .
8085 8086 In addition to mailing the developers, it would be a good idea to file
8086 8087 a bug report here.
8087 8088 This will ensure that the issue is properly followed to conclusion.
8088 8089 \layout Standard
8089 8090
8090 8091 You can also use this bug tracker to file feature requests.
8091 8092 \layout Section
8092 8093
8093 8094 Brief history
8094 8095 \layout Subsection
8095 8096
8096 8097 Origins
8097 8098 \layout Standard
8098 8099
8099 8100 The current IPython system grew out of the following three projects:
8100 8101 \layout List
8101 8102 \labelwidthstring 00.00.0000
8102 8103
8103 8104 ipython by Fernando PοΏ½rez.
8104 8105 I was working on adding Mathematica-type prompts and a flexible configuration
8105 8106 system (something better than
8106 8107 \family typewriter
8107 8108 $PYTHONSTARTUP
8108 8109 \family default
8109 8110 ) to the standard Python interactive interpreter.
8110 8111 \layout List
8111 8112 \labelwidthstring 00.00.0000
8112 8113
8113 8114 IPP by Janko Hauser.
8114 8115 Very well organized, great usability.
8115 8116 Had an old help system.
8116 8117 IPP was used as the `container' code into which I added the functionality
8117 8118 from ipython and LazyPython.
8118 8119 \layout List
8119 8120 \labelwidthstring 00.00.0000
8120 8121
8121 8122 LazyPython by Nathan Gray.
8122 8123 Simple but
8123 8124 \emph on
8124 8125 very
8125 8126 \emph default
8126 8127 powerful.
8127 8128 The quick syntax (auto parens, auto quotes) and verbose/colored tracebacks
8128 8129 were all taken from here.
8129 8130 \layout Standard
8130 8131
8131 8132 When I found out (see sec.
8132 8133
8133 8134 \begin_inset LatexCommand \ref{figgins}
8134 8135
8135 8136 \end_inset
8136 8137
8137 8138 ) about IPP and LazyPython I tried to join all three into a unified system.
8138 8139 I thought this could provide a very nice working environment, both for
8139 8140 regular programming and scientific computing: shell-like features, IDL/Matlab
8140 8141 numerics, Mathematica-type prompt history and great object introspection
8141 8142 and help facilities.
8142 8143 I think it worked reasonably well, though it was a lot more work than I
8143 8144 had initially planned.
8144 8145 \layout Subsection
8145 8146
8146 8147 Current status
8147 8148 \layout Standard
8148 8149
8149 8150 The above listed features work, and quite well for the most part.
8150 8151 But until a major internal restructuring is done (see below), only bug
8151 8152 fixing will be done, no other features will be added (unless very minor
8152 8153 and well localized in the cleaner parts of the code).
8153 8154 \layout Standard
8154 8155
8155 8156 IPython consists of some 12000 lines of pure python code, of which roughly
8156 8157 50% are fairly clean.
8157 8158 The other 50% are fragile, messy code which needs a massive restructuring
8158 8159 before any further major work is done.
8159 8160 Even the messy code is fairly well documented though, and most of the problems
8160 8161 in the (non-existent) class design are well pointed to by a PyChecker run.
8161 8162 So the rewriting work isn't that bad, it will just be time-consuming.
8162 8163 \layout Subsection
8163 8164
8164 8165 Future
8165 8166 \layout Standard
8166 8167
8167 8168 See the separate
8168 8169 \family typewriter
8169 8170 new_design
8170 8171 \family default
8171 8172 document for details.
8172 8173 Ultimately, I would like to see IPython become part of the standard Python
8173 8174 distribution as a `big brother with batteries' to the standard Python interacti
8174 8175 ve interpreter.
8175 8176 But that will never happen with the current state of the code, so all contribut
8176 8177 ions are welcome.
8177 8178 \layout Section
8178 8179
8179 8180 License
8180 8181 \layout Standard
8181 8182
8182 8183 IPython is released under the terms of the BSD license, whose general form
8183 8184 can be found at:
8184 8185 \begin_inset LatexCommand \htmlurl{http://www.opensource.org/licenses/bsd-license.php}
8185 8186
8186 8187 \end_inset
8187 8188
8188 8189 .
8189 8190 The full text of the IPython license is reproduced below:
8190 8191 \layout Quote
8191 8192
8192 8193
8193 8194 \family typewriter
8194 8195 \size small
8195 8196 IPython is released under a BSD-type license.
8196 8197 \layout Quote
8197 8198
8198 8199
8199 8200 \family typewriter
8200 8201 \size small
8201 8202 Copyright (c) 2001, 2002, 2003, 2004 Fernando Perez <fperez@colorado.edu>.
8202 8203 \layout Quote
8203 8204
8204 8205
8205 8206 \family typewriter
8206 8207 \size small
8207 8208 Copyright (c) 2001 Janko Hauser <jhauser@zscout.de> and
8208 8209 \newline
8209 8210 Nathaniel Gray <n8gray@caltech.edu>.
8210 8211 \layout Quote
8211 8212
8212 8213
8213 8214 \family typewriter
8214 8215 \size small
8215 8216 All rights reserved.
8216 8217 \layout Quote
8217 8218
8218 8219
8219 8220 \family typewriter
8220 8221 \size small
8221 8222 Redistribution and use in source and binary forms, with or without modification,
8222 8223 are permitted provided that the following conditions are met:
8223 8224 \layout Quote
8224 8225
8225 8226
8226 8227 \family typewriter
8227 8228 \size small
8228 8229 a.
8229 8230 Redistributions of source code must retain the above copyright notice,
8230 8231 this list of conditions and the following disclaimer.
8231 8232 \layout Quote
8232 8233
8233 8234
8234 8235 \family typewriter
8235 8236 \size small
8236 8237 b.
8237 8238 Redistributions in binary form must reproduce the above copyright notice,
8238 8239 this list of conditions and the following disclaimer in the documentation
8239 8240 and/or other materials provided with the distribution.
8240 8241 \layout Quote
8241 8242
8242 8243
8243 8244 \family typewriter
8244 8245 \size small
8245 8246 c.
8246 8247 Neither the name of the copyright holders nor the names of any contributors
8247 8248 to this software may be used to endorse or promote products derived from
8248 8249 this software without specific prior written permission.
8249 8250 \layout Quote
8250 8251
8251 8252
8252 8253 \family typewriter
8253 8254 \size small
8254 8255 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
8255 8256 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
8256 8257 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
8257 8258 PURPOSE ARE DISCLAIMED.
8258 8259 IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
8259 8260 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
8260 8261 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
8261 8262 USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
8262 8263 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
8263 8264 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
8264 8265 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8265 8266
8266 8267 \layout Standard
8267 8268
8268 8269 Individual authors are the holders of the copyright for their code and are
8269 8270 listed in each file.
8270 8271 \layout Standard
8271 8272
8272 8273 Some files (
8273 8274 \family typewriter
8274 8275 DPyGetOpt.py
8275 8276 \family default
8276 8277 , for example) may be licensed under different conditions.
8277 8278 Ultimately each file indicates clearly the conditions under which its author/au
8278 8279 thors have decided to publish the code.
8279 8280 \layout Standard
8280 8281
8281 8282 Versions of IPython up to and including 0.6.3 were released under the GNU
8282 8283 Lesser General Public License (LGPL), available at
8283 8284 \begin_inset LatexCommand \htmlurl{http://www.gnu.org/copyleft/lesser.html}
8284 8285
8285 8286 \end_inset
8286 8287
8287 8288 .
8288 8289 \layout Section
8289 8290
8290 8291
8291 8292 \begin_inset LatexCommand \label{sec:credits}
8292 8293
8293 8294 \end_inset
8294 8295
8295 8296 Credits
8296 8297 \layout Standard
8297 8298
8298 8299 IPython is mainly developed by Fernando PοΏ½rez
8299 8300 \family typewriter
8300 8301 <fperez@colorado.edu>
8301 8302 \family default
8302 8303 , but the project was born from mixing in Fernando's code with the IPP project
8303 8304 by Janko Hauser
8304 8305 \family typewriter
8305 8306 <jhauser-AT-zscout.de>
8306 8307 \family default
8307 8308 and LazyPython by Nathan Gray
8308 8309 \family typewriter
8309 8310 <n8gray-AT-caltech.edu>
8310 8311 \family default
8311 8312 .
8312 8313 For all IPython-related requests, please contact Fernando.
8313 8314 User or development help should be requested via the IPython mailing lists:
8314 8315 \layout Description
8315 8316
8316 8317 User\SpecialChar ~
8317 8318 list:
8318 8319 \begin_inset LatexCommand \htmlurl{http://scipy.net/mailman/listinfo/ipython-user}
8319 8320
8320 8321 \end_inset
8321 8322
8322 8323
8323 8324 \layout Description
8324 8325
8325 8326 Developer's\SpecialChar ~
8326 8327 list:
8327 8328 \begin_inset LatexCommand \htmlurl{http://scipy.net/mailman/listinfo/ipython-dev}
8328 8329
8329 8330 \end_inset
8330 8331
8331 8332
8332 8333 \layout Standard
8333 8334
8334 8335 The IPython project is also very grateful to
8335 8336 \begin_inset Foot
8336 8337 collapsed true
8337 8338
8338 8339 \layout Standard
8339 8340
8340 8341 I've mangled email addresses to reduce spam, since the IPython manuals can
8341 8342 be accessed online.
8342 8343 \end_inset
8343 8344
8344 8345 :
8345 8346 \layout Standard
8346 8347
8347 8348 Bill Bumgarner
8348 8349 \family typewriter
8349 8350 <bbum-AT-friday.com>
8350 8351 \family default
8351 8352 : for providing the DPyGetOpt module which gives very powerful and convenient
8352 8353 handling of command-line options (light years ahead of what Python 2.1.1's
8353 8354 getopt module does).
8354 8355 \layout Standard
8355 8356
8356 8357 Ka-Ping Yee
8357 8358 \family typewriter
8358 8359 <ping-AT-lfw.org>
8359 8360 \family default
8360 8361 : for providing the Itpl module for convenient and powerful string interpolation
8361 8362 with a much nicer syntax than formatting through the '%' operator.
8362 8363 \layout Standard
8363 8364
8364 8365 Arnd BοΏ½cker
8365 8366 \family typewriter
8366 8367 <baecker-AT-physik.tu-dresden.de>
8367 8368 \family default
8368 8369 : for his many very useful suggestions and comments, and lots of help with
8369 8370 testing and documentation checking.
8370 8371 Many of IPython's newer features are a result of discussions with him (bugs
8371 8372 are still my fault, not his).
8372 8373 \layout Standard
8373 8374
8374 8375 Obviously Guido van\SpecialChar ~
8375 8376 Rossum and the whole Python development team, that goes
8376 8377 without saying.
8377 8378 \layout Standard
8378 8379
8379 8380 IPython's website is generously hosted at
8380 8381 \begin_inset LatexCommand \htmlurl{http://ipython.scipy.org}
8381 8382
8382 8383 \end_inset
8383 8384
8384 8385 by Enthought (
8385 8386 \begin_inset LatexCommand \htmlurl{http://www.enthought.com}
8386 8387
8387 8388 \end_inset
8388 8389
8389 8390 ).
8390 8391 I am very grateful to them and all of the SciPy team for their contribution.
8391 8392 \layout Standard
8392 8393
8393 8394
8394 8395 \begin_inset LatexCommand \label{figgins}
8395 8396
8396 8397 \end_inset
8397 8398
8398 8399 Fernando would also like to thank Stephen Figgins
8399 8400 \family typewriter
8400 8401 <fig-AT-monitor.net>
8401 8402 \family default
8402 8403 , an O'Reilly Python editor.
8403 8404 His Oct/11/2001 article about IPP and LazyPython, was what got this project
8404 8405 started.
8405 8406 You can read it at:
8406 8407 \begin_inset LatexCommand \htmlurl{http://www.onlamp.com/pub/a/python/2001/10/11/pythonnews.html}
8407 8408
8408 8409 \end_inset
8409 8410
8410 8411 .
8411 8412 \layout Standard
8412 8413
8413 8414 And last but not least, all the kind IPython users who have emailed new
8414 8415 code, bug reports, fixes, comments and ideas.
8415 8416 A brief list follows, please let me know if I have ommitted your name by
8416 8417 accident:
8417 8418 \layout List
8418 8419 \labelwidthstring 00.00.0000
8419 8420
8420 8421 Jack\SpecialChar ~
8421 8422 Moffit
8422 8423 \family typewriter
8423 8424 <jack-AT-xiph.org>
8424 8425 \family default
8425 8426 Bug fixes, including the infamous color problem.
8426 8427 This bug alone caused many lost hours and frustration, many thanks to him
8427 8428 for the fix.
8428 8429 I've always been a fan of Ogg & friends, now I have one more reason to
8429 8430 like these folks.
8430 8431 \newline
8431 8432 Jack is also contributing with Debian packaging and many other things.
8432 8433 \layout List
8433 8434 \labelwidthstring 00.00.0000
8434 8435
8435 8436 Alexander\SpecialChar ~
8436 8437 Schmolck
8437 8438 \family typewriter
8438 8439 <a.schmolck-AT-gmx.net>
8439 8440 \family default
8440 8441 Emacs work, bug reports, bug fixes, ideas, lots more.
8441 8442 The ipython.el mode for (X)Emacs is Alex's code, providing full support
8442 8443 for IPython under (X)Emacs.
8443 8444 \layout List
8444 8445 \labelwidthstring 00.00.0000
8445 8446
8446 8447 Andrea\SpecialChar ~
8447 8448 Riciputi
8448 8449 \family typewriter
8449 8450 <andrea.riciputi-AT-libero.it>
8450 8451 \family default
8451 8452 Mac OSX information, Fink package management.
8452 8453 \layout List
8453 8454 \labelwidthstring 00.00.0000
8454 8455
8455 8456 Gary\SpecialChar ~
8456 8457 Bishop
8457 8458 \family typewriter
8458 8459 <gb-AT-cs.unc.edu>
8459 8460 \family default
8460 8461 Bug reports, and patches to work around the exception handling idiosyncracies
8461 8462 of WxPython.
8462 8463 Readline and color support for Windows.
8463 8464 \layout List
8464 8465 \labelwidthstring 00.00.0000
8465 8466
8466 8467 Jeffrey\SpecialChar ~
8467 8468 Collins
8468 8469 \family typewriter
8469 8470 <Jeff.Collins-AT-vexcel.com>
8470 8471 \family default
8471 8472 Bug reports.
8472 8473 Much improved readline support, including fixes for Python 2.3.
8473 8474 \layout List
8474 8475 \labelwidthstring 00.00.0000
8475 8476
8476 8477 Dryice\SpecialChar ~
8477 8478 Liu
8478 8479 \family typewriter
8479 8480 <dryice-AT-liu.com.cn>
8480 8481 \family default
8481 8482 FreeBSD port.
8482 8483 \layout List
8483 8484 \labelwidthstring 00.00.0000
8484 8485
8485 8486 Mike\SpecialChar ~
8486 8487 Heeter
8487 8488 \family typewriter
8488 8489 <korora-AT-SDF.LONESTAR.ORG>
8489 8490 \layout List
8490 8491 \labelwidthstring 00.00.0000
8491 8492
8492 8493 Christopher\SpecialChar ~
8493 8494 Hart
8494 8495 \family typewriter
8495 8496 <hart-AT-caltech.edu>
8496 8497 \family default
8497 8498 PDB integration.
8498 8499 \layout List
8499 8500 \labelwidthstring 00.00.0000
8500 8501
8501 8502 Milan\SpecialChar ~
8502 8503 Zamazal
8503 8504 \family typewriter
8504 8505 <pdm-AT-zamazal.org>
8505 8506 \family default
8506 8507 Emacs info.
8507 8508 \layout List
8508 8509 \labelwidthstring 00.00.0000
8509 8510
8510 8511 Philip\SpecialChar ~
8511 8512 Hisley
8512 8513 \family typewriter
8513 8514 <compsys-AT-starpower.net>
8514 8515 \layout List
8515 8516 \labelwidthstring 00.00.0000
8516 8517
8517 8518 Holger\SpecialChar ~
8518 8519 Krekel
8519 8520 \family typewriter
8520 8521 <pyth-AT-devel.trillke.net>
8521 8522 \family default
8522 8523 Tab completion, lots more.
8523 8524 \layout List
8524 8525 \labelwidthstring 00.00.0000
8525 8526
8526 8527 Robin\SpecialChar ~
8527 8528 Siebler
8528 8529 \family typewriter
8529 8530 <robinsiebler-AT-starband.net>
8530 8531 \layout List
8531 8532 \labelwidthstring 00.00.0000
8532 8533
8533 8534 Ralf\SpecialChar ~
8534 8535 Ahlbrink
8535 8536 \family typewriter
8536 8537 <ralf_ahlbrink-AT-web.de>
8537 8538 \layout List
8538 8539 \labelwidthstring 00.00.0000
8539 8540
8540 8541 Thorsten\SpecialChar ~
8541 8542 Kampe
8542 8543 \family typewriter
8543 8544 <thorsten-AT-thorstenkampe.de>
8544 8545 \layout List
8545 8546 \labelwidthstring 00.00.0000
8546 8547
8547 8548 Fredrik\SpecialChar ~
8548 8549 Kant
8549 8550 \family typewriter
8550 8551 <fredrik.kant-AT-front.com>
8551 8552 \family default
8552 8553 Windows setup.
8553 8554 \layout List
8554 8555 \labelwidthstring 00.00.0000
8555 8556
8556 8557 Syver\SpecialChar ~
8557 8558 Enstad
8558 8559 \family typewriter
8559 8560 <syver-en-AT-online.no>
8560 8561 \family default
8561 8562 Windows setup.
8562 8563 \layout List
8563 8564 \labelwidthstring 00.00.0000
8564 8565
8565 8566 Richard
8566 8567 \family typewriter
8567 8568 <rxe-AT-renre-europe.com>
8568 8569 \family default
8569 8570 Global embedding.
8570 8571 \layout List
8571 8572 \labelwidthstring 00.00.0000
8572 8573
8573 8574 Hayden\SpecialChar ~
8574 8575 Callow
8575 8576 \family typewriter
8576 8577 <h.callow-AT-elec.canterbury.ac.nz>
8577 8578 \family default
8578 8579 Gnuplot.py 1.6 compatibility.
8579 8580 \layout List
8580 8581 \labelwidthstring 00.00.0000
8581 8582
8582 8583 Leonardo\SpecialChar ~
8583 8584 Santagada
8584 8585 \family typewriter
8585 8586 <retype-AT-terra.com.br>
8586 8587 \family default
8587 8588 Fixes for Windows installation.
8588 8589 \layout List
8589 8590 \labelwidthstring 00.00.0000
8590 8591
8591 8592 Christopher\SpecialChar ~
8592 8593 Armstrong
8593 8594 \family typewriter
8594 8595 <radix-AT-twistedmatrix.com>
8595 8596 \family default
8596 8597 Bugfixes.
8597 8598 \layout List
8598 8599 \labelwidthstring 00.00.0000
8599 8600
8600 8601 Francois\SpecialChar ~
8601 8602 Pinard
8602 8603 \family typewriter
8603 8604 <pinard-AT-iro.umontreal.ca>
8604 8605 \family default
8605 8606 Code and documentation fixes.
8606 8607 \layout List
8607 8608 \labelwidthstring 00.00.0000
8608 8609
8609 8610 Cory\SpecialChar ~
8610 8611 Dodt
8611 8612 \family typewriter
8612 8613 <cdodt-AT-fcoe.k12.ca.us>
8613 8614 \family default
8614 8615 Bug reports and Windows ideas.
8615 8616 Patches for Windows installer.
8616 8617 \layout List
8617 8618 \labelwidthstring 00.00.0000
8618 8619
8619 8620 Olivier\SpecialChar ~
8620 8621 Aubert
8621 8622 \family typewriter
8622 8623 <oaubert-AT-bat710.univ-lyon1.fr>
8623 8624 \family default
8624 8625 New magics.
8625 8626 \layout List
8626 8627 \labelwidthstring 00.00.0000
8627 8628
8628 8629 King\SpecialChar ~
8629 8630 C.\SpecialChar ~
8630 8631 Shu
8631 8632 \family typewriter
8632 8633 <kingshu-AT-myrealbox.com>
8633 8634 \family default
8634 8635 Autoindent patch.
8635 8636 \layout List
8636 8637 \labelwidthstring 00.00.0000
8637 8638
8638 8639 Chris\SpecialChar ~
8639 8640 Drexler
8640 8641 \family typewriter
8641 8642 <chris-AT-ac-drexler.de>
8642 8643 \family default
8643 8644 Readline packages for Win32/CygWin.
8644 8645 \layout List
8645 8646 \labelwidthstring 00.00.0000
8646 8647
8647 8648 Gustavo\SpecialChar ~
8648 8649 CοΏ½rdova\SpecialChar ~
8649 8650 Avila
8650 8651 \family typewriter
8651 8652 <gcordova-AT-sismex.com>
8652 8653 \family default
8653 8654 EvalDict code for nice, lightweight string interpolation.
8654 8655 \layout List
8655 8656 \labelwidthstring 00.00.0000
8656 8657
8657 8658 Kasper\SpecialChar ~
8658 8659 Souren
8659 8660 \family typewriter
8660 8661 <Kasper.Souren-AT-ircam.fr>
8661 8662 \family default
8662 8663 Bug reports, ideas.
8663 8664 \layout List
8664 8665 \labelwidthstring 00.00.0000
8665 8666
8666 8667 Gever\SpecialChar ~
8667 8668 Tulley
8668 8669 \family typewriter
8669 8670 <gever-AT-helium.com>
8670 8671 \family default
8671 8672 Code contributions.
8672 8673 \layout List
8673 8674 \labelwidthstring 00.00.0000
8674 8675
8675 8676 Ralf\SpecialChar ~
8676 8677 Schmitt
8677 8678 \family typewriter
8678 8679 <ralf-AT-brainbot.com>
8679 8680 \family default
8680 8681 Bug reports & fixes.
8681 8682 \layout List
8682 8683 \labelwidthstring 00.00.0000
8683 8684
8684 8685 Oliver\SpecialChar ~
8685 8686 Sander
8686 8687 \family typewriter
8687 8688 <osander-AT-gmx.de>
8688 8689 \family default
8689 8690 Bug reports.
8690 8691 \layout List
8691 8692 \labelwidthstring 00.00.0000
8692 8693
8693 8694 Rod\SpecialChar ~
8694 8695 Holland
8695 8696 \family typewriter
8696 8697 <rhh-AT-structurelabs.com>
8697 8698 \family default
8698 8699 Bug reports and fixes to logging module.
8699 8700 \layout List
8700 8701 \labelwidthstring 00.00.0000
8701 8702
8702 8703 Daniel\SpecialChar ~
8703 8704 'Dang'\SpecialChar ~
8704 8705 Griffith
8705 8706 \family typewriter
8706 8707 <pythondev-dang-AT-lazytwinacres.net>
8707 8708 \family default
8708 8709 Fixes, enhancement suggestions for system shell use.
8709 8710 \layout List
8710 8711 \labelwidthstring 00.00.0000
8711 8712
8712 8713 Viktor\SpecialChar ~
8713 8714 Ransmayr
8714 8715 \family typewriter
8715 8716 <viktor.ransmayr-AT-t-online.de>
8716 8717 \family default
8717 8718 Tests and reports on Windows installation issues.
8718 8719 Contributed a true Windows binary installer.
8719 8720 \layout List
8720 8721 \labelwidthstring 00.00.0000
8721 8722
8722 8723 Mike\SpecialChar ~
8723 8724 Salib
8724 8725 \family typewriter
8725 8726 <msalib-AT-mit.edu>
8726 8727 \family default
8727 8728 Help fixing a subtle bug related to traceback printing.
8728 8729 \layout List
8729 8730 \labelwidthstring 00.00.0000
8730 8731
8731 8732 W.J.\SpecialChar ~
8732 8733 van\SpecialChar ~
8733 8734 der\SpecialChar ~
8734 8735 Laan
8735 8736 \family typewriter
8736 8737 <gnufnork-AT-hetdigitalegat.nl>
8737 8738 \family default
8738 8739 Bash-like prompt specials.
8739 8740 \layout List
8740 8741 \labelwidthstring 00.00.0000
8741 8742
8742 8743 Ville\SpecialChar ~
8743 8744 Vainio
8744 8745 \family typewriter
8745 8746 <vivainio-AT-kolumbus.fi>
8746 8747 \family default
8747 8748 Bugfixes and suggestions.
8748 8749 Excellent patches for many new features.
8749 8750 \layout List
8750 8751 \labelwidthstring 00.00.0000
8751 8752
8752 8753 Antoon\SpecialChar ~
8753 8754 Pardon
8754 8755 \family typewriter
8755 8756 <Antoon.Pardon-AT-rece.vub.ac.be>
8756 8757 \family default
8757 8758 Critical fix for the multithreaded IPython.
8758 8759 \layout List
8759 8760 \labelwidthstring 00.00.0000
8760 8761
8761 8762 John\SpecialChar ~
8762 8763 Hunter
8763 8764 \family typewriter
8764 8765 <jdhunter-AT-nitace.bsd.uchicago.edu>
8765 8766 \family default
8766 8767 Matplotlib author, helped with all the development of support for matplotlib
8767 8768 in IPyhton, including making necessary changes to matplotlib itself.
8768 8769 \layout List
8769 8770 \labelwidthstring 00.00.0000
8770 8771
8771 8772 Matthew\SpecialChar ~
8772 8773 Arnison
8773 8774 \family typewriter
8774 8775 <maffew-AT-cat.org.au>
8775 8776 \family default
8776 8777 Bug reports, `
8777 8778 \family typewriter
8778 8779 %run -d
8779 8780 \family default
8780 8781 ' idea.
8781 8782 \layout List
8782 8783 \labelwidthstring 00.00.0000
8783 8784
8784 8785 Prabhu\SpecialChar ~
8785 8786 Ramachandran
8786 8787 \family typewriter
8787 8788 <prabhu_r-AT-users.sourceforge.net>
8788 8789 \family default
8789 8790 Help with (X)Emacs support, threading patches, ideas...
8790 8791 \layout List
8791 8792 \labelwidthstring 00.00.0000
8792 8793
8793 8794 Norbert\SpecialChar ~
8794 8795 Tretkowski
8795 8796 \family typewriter
8796 8797 <tretkowski-AT-inittab.de>
8797 8798 \family default
8798 8799 help with Debian packaging and distribution.
8799 8800 \layout List
8800 8801 \labelwidthstring 00.00.0000
8801 8802
8802 8803 Robert\SpecialChar ~
8803 8804 Kern
8804 8805 \family typewriter
8805 8806 <rkern-AT-ucsd.edu>
8806 8807 \family default
8807 8808 help with OSX issues, much help in general with various Python topics,
8808 8809 especially related to scientific computing.
8809 8810 \layout List
8810 8811 \labelwidthstring 00.00.0000
8811 8812
8812 8813 George\SpecialChar ~
8813 8814 Sakkis <
8814 8815 \family typewriter
8815 8816 gsakkis-AT-eden.rutgers.edu>
8816 8817 \family default
8817 8818 New matcher for tab-completing named arguments of user-defined functions.
8818 8819 \the_end
General Comments 0
You need to be logged in to leave comments. Login now