Show More
@@ -8,7 +8,7 b' Overview' | |||
|
8 | 8 | ======== |
|
9 | 9 | |
|
10 | 10 | One of Python's most useful features is its interactive interpreter. |
|
11 |
|
|
|
11 | It allows for very fast testing of ideas without the overhead of | |
|
12 | 12 | creating test files as is typical in most programming languages. |
|
13 | 13 | However, the interpreter supplied with the standard Python distribution |
|
14 | 14 | is somewhat limited for extended interactive use. |
@@ -32,29 +32,28 b" IPython's interactive shell (:command:`ipython`), has the following goals," | |||
|
32 | 32 | amongst others: |
|
33 | 33 | |
|
34 | 34 | 1. Provide an interactive shell superior to Python's default. IPython |
|
35 |
has many features for object introspection, system shell |
|
|
36 | and its own special command system for adding functionality when | |
|
37 | working interactively. It tries to be a very efficient environment | |
|
38 | both for Python code development and for exploration of problems | |
|
39 |
using Python objects (in situations like |
|
|
35 | has many features for tab-completion, object introspection, system shell | |
|
36 | access, command history retrieval across sessions, and its own special | |
|
37 | command system for adding functionality when working interactively. It | |
|
38 | tries to be a very efficient environment both for Python code development | |
|
39 | and for exploration of problems using Python objects (in situations like | |
|
40 | data analysis). | |
|
40 | 41 | |
|
41 | 42 | 2. Serve as an embeddable, ready to use interpreter for your own |
|
42 |
programs. IPython can be started with a single call |
|
|
43 |
another program, providing access to the current namespace. |
|
|
44 | can be very useful both for debugging purposes and for situations | |
|
45 | where a blend of batch-processing and interactive exploration are | |
|
46 | needed. New in the 0.9 version of IPython is a reusable wxPython | |
|
47 | based IPython widget. | |
|
43 | programs. An interactive IPython shell can be started with a single call | |
|
44 | from inside another program, providing access to the current namespace. | |
|
45 | This can be very useful both for debugging purposes and for situations | |
|
46 | where a blend of batch-processing and interactive exploration are needed. | |
|
48 | 47 | |
|
49 | 48 | 3. Offer a flexible framework which can be used as the base |
|
50 | environment for other systems with Python as the underlying | |
|
51 | language. Specifically scientific environments like Mathematica, | |
|
49 | environment for working with other systems, with Python as the underlying | |
|
50 | bridge language. Specifically scientific environments like Mathematica, | |
|
52 | 51 | IDL and Matlab inspired its design, but similar ideas can be |
|
53 | 52 | useful in many fields. |
|
54 | 53 | |
|
55 | 54 | 4. Allow interactive testing of threaded graphical toolkits. IPython |
|
56 | has support for interactive, non-blocking control of GTK, Qt and | |
|
57 |
|
|
|
55 | has support for interactive, non-blocking control of GTK, Qt, WX, GLUT, and | |
|
56 | OS X applications via special threading flags. The normal Python | |
|
58 | 57 | shell can only do this for Tkinter applications. |
|
59 | 58 | |
|
60 | 59 | Main features of the interactive shell |
@@ -90,10 +89,6 b' Main features of the interactive shell' | |||
|
90 | 89 | directly to the system shell, and using :samp:`!!` or :samp:`var = !cmd` |
|
91 | 90 | captures shell output into python variables for further use. |
|
92 | 91 | |
|
93 | * Background execution of Python commands in a separate thread. | |
|
94 | IPython has an internal job manager called jobs, and a | |
|
95 | convenience backgrounding magic function called :samp:`%bg`. | |
|
96 | ||
|
97 | 92 | * The ability to expand python variables when calling the system shell. In a |
|
98 | 93 | shell command, any python variable prefixed with :samp:`$` is expanded. A |
|
99 | 94 | double :samp:`$$` allows passing a literal :samp:`$` to the shell (for access |
@@ -105,14 +100,14 b' Main features of the interactive shell' | |||
|
105 | 100 | |
|
106 | 101 | * A lightweight persistence framework via the :samp:`%store` command, which |
|
107 | 102 | allows you to save arbitrary Python variables. These get restored |
|
108 | automatically when your session restarts. | |
|
103 | when you run the :samp:`%store -r` command. | |
|
109 | 104 | |
|
110 | 105 | * Automatic indentation (optional) of code as you type (through the |
|
111 | 106 | readline library). |
|
112 | 107 | |
|
113 | 108 | * Macro system for quickly re-executing multiple lines of previous |
|
114 | input with a single name. Macros can be stored persistently via | |
|
115 | :samp:`%store` and edited via :samp:`%edit`. | |
|
109 | input with a single name via the :samp:`%macro` command. Macros can be | |
|
110 | stored persistently via :samp:`%store` and edited via :samp:`%edit`. | |
|
116 | 111 | |
|
117 | 112 | * Session logging (you can then later use these logs as code in your |
|
118 | 113 | programs). Logs can optionally timestamp all input, and also store |
@@ -127,8 +122,9 b' Main features of the interactive shell' | |||
|
127 | 122 | debugging information (basically a terminal version of the cgitb |
|
128 | 123 | module). |
|
129 | 124 | |
|
130 |
* Auto-parentheses: callable objects can be |
|
|
131 |
parentheses: :samp:`sin 3` is automatically converted to |
|
|
125 | * Auto-parentheses via the :samp:`%autocall` command: callable objects can be | |
|
126 | executed without parentheses: :samp:`sin 3` is automatically converted to | |
|
127 | :samp:`sin(3)` | |
|
132 | 128 | |
|
133 | 129 | * Auto-quoting: using :samp:`,`, or :samp:`;` as the first character forces |
|
134 | 130 | auto-quoting of the rest of the line: :samp:`,my_function a b` becomes |
@@ -141,11 +137,11 b' Main features of the interactive shell' | |||
|
141 | 137 | :samp:`>>>` or :samp:`...` such as those from other python sessions or the |
|
142 | 138 | standard Python documentation. |
|
143 | 139 | |
|
144 |
* Flexible configuration system |
|
|
145 |
allows permanent setting of all command-line |
|
|
146 |
loading, code and file execution. The system allows |
|
|
147 |
inclusion, so you can have a base file with defaults and |
|
|
148 | which load other customizations for particular projects. | |
|
140 | * Flexible :ref:`configuration system <config_overview>`. It uses a | |
|
141 | configuration file which allows permanent setting of all command-line | |
|
142 | options, module loading, code and file execution. The system allows | |
|
143 | recursive file inclusion, so you can have a base file with defaults and | |
|
144 | layers which load other customizations for particular projects. | |
|
149 | 145 | |
|
150 | 146 | * Embeddable. You can call IPython as a python shell inside your own |
|
151 | 147 | python programs. This can be used both for debugging code or for |
@@ -161,8 +157,7 b' Main features of the interactive shell' | |||
|
161 | 157 | any script under pdb's control, automatically setting initial breakpoints for |
|
162 | 158 | you. This version of pdb has IPython-specific improvements, including |
|
163 | 159 | tab-completion and traceback coloring support. For even easier debugger |
|
164 |
access, try :samp:`%debug` after seeing an exception. |
|
|
165 | supported, see ipy_winpdb extension. | |
|
160 | access, try :samp:`%debug` after seeing an exception. | |
|
166 | 161 | |
|
167 | 162 | * Profiler support. You can run single statements (similar to |
|
168 | 163 | :samp:`profile.run()`) or complete programs under the profiler's control. |
@@ -170,10 +165,30 b' Main features of the interactive shell' | |||
|
170 | 165 | IPython wraps this functionality with magic commands (see :samp:`%prun` |
|
171 | 166 | and :samp:`%run -p`) convenient for rapid interactive work. |
|
172 | 167 | |
|
168 | * Simple timing information. You can use the :samp:`%timeit` command to get | |
|
169 | the execution time of a Python statement or expression. This machinery is | |
|
170 | intelligent enough to do more repetitions for commands that finish very | |
|
171 | quickly in order to get a better estimate of their running time. | |
|
172 | ||
|
173 | .. sourcecode:: ipython | |
|
174 | ||
|
175 | In [1]: %timeit 1+1 | |
|
176 | 10000000 loops, best of 3: 25.5 ns per loop | |
|
177 | ||
|
178 | In [2]: %timeit [math.sin(x) for x in range(5000)] | |
|
179 | 1000 loops, best of 3: 719 µs per loop | |
|
180 | ||
|
181 | .. | |
|
182 | ||
|
183 | To get the timing information for more than one expression, use the | |
|
184 | :samp:`%%timeit` cell magic command. | |
|
185 | ||
|
186 | ||
|
173 | 187 | * Doctest support. The special :samp:`%doctest_mode` command toggles a mode |
|
174 | that allows you to paste existing doctests (with leading :samp:`>>>` | |
|
175 | prompts and whitespace) and uses doctest-compatible prompts and | |
|
176 | output, so you can use IPython sessions as doctest code. | |
|
188 | to use doctest-compatible prompts, so you can use IPython sessions as | |
|
189 | doctest code. By default, IPython also allows you to paste existing | |
|
190 | doctests, and strips out the leading :samp:`>>>` and :samp:`...` prompts in | |
|
191 | them. | |
|
177 | 192 | |
|
178 | 193 | .. _ipythonzmq: |
|
179 | 194 | |
@@ -254,11 +269,10 b' for parallel computing.' | |||
|
254 | 269 | Portability and Python requirements |
|
255 | 270 | ----------------------------------- |
|
256 | 271 | |
|
257 |
As of the 0 |
|
|
258 | 0.10 worked with Python 2.4 and above. IPython now also supports Python 3, | |
|
259 | although for now the code for this is separate, and kept up to date with the | |
|
260 | main IPython repository. In the future, these will converge to a single codebase | |
|
261 | which can be automatically translated using 2to3. | |
|
272 | As of the 1.0 release, IPython works with Python 2.6, 2.7, 3.2 and 3.3. | |
|
273 | Version 0.12 introduced full support for Python 3. Version 0.11 worked with | |
|
274 | Python 2.6 and 2.7 only. Versions 0.9 and 0.10 worked with Python 2.4 and | |
|
275 | above (not including Python 3). | |
|
262 | 276 | |
|
263 | 277 | IPython is known to work on the following operating systems: |
|
264 | 278 |
General Comments 0
You need to be logged in to leave comments.
Login now