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