##// END OF EJS Templates
fixed typo in overview.rst
Justin Jent -
Show More
@@ -1,256 +1,256 b''
1 .. _overview:
1 .. _overview:
2
2
3 ========
3 ========
4 Overview
4 Overview
5 ========
5 ========
6
6
7 One of Python's most useful features is its interactive interpreter.
7 One of Python's most useful features is its interactive interpreter.
8 It allows for very fast testing of ideas without the overhead of
8 It allows for very fast testing of ideas without the overhead of
9 creating test files as is typical in most programming languages.
9 creating test files as is typical in most programming languages.
10 However, the interpreter supplied with the standard Python distribution
10 However, the interpreter supplied with the standard Python distribution
11 is somewhat limited for extended interactive use.
11 is somewhat limited for extended interactive use.
12
12
13 The goal of IPython is to create a comprehensive environment for
13 The goal of IPython is to create a comprehensive environment for
14 interactive and exploratory computing. To support this goal, IPython
14 interactive and exploratory computing. To support this goal, IPython
15 has three main components:
15 has three main components:
16
16
17 * An enhanced interactive Python shell.
17 * An enhanced interactive Python shell.
18
18
19 * A decoupled :ref:`two-process communication model <ipythonzmq>`, which
19 * A decoupled :ref:`two-process communication model <ipythonzmq>`, which
20 allows for multiple clients to connect to a computation kernel, most notably
20 allows for multiple clients to connect to a computation kernel, most notably
21 the web-based notebook provided with `Jupyter <https://jupyter.org>`_.
21 the web-based notebook provided with `Jupyter <https://jupyter.org>`_.
22
22
23 * An architecture for interactive parallel computing now part of the
23 * An architecture for interactive parallel computing now part of the
24 `ipyparallel` package.
24 `ipyparallel` package.
25
25
26 All of IPython is open source (released under the revised BSD license).
26 All of IPython is open source (released under the revised BSD license).
27
27
28 Enhanced interactive Python shell
28 Enhanced interactive Python shell
29 =================================
29 =================================
30
30
31 IPython's interactive shell (:command:`ipython`), has the following goals,
31 IPython's interactive shell (:command:`ipython`), has the following goals,
32 amongst others:
32 amongst others:
33
33
34 1. Provide an interactive shell superior to Python's default. IPython
34 1. Provide an interactive shell superior to Python's default. IPython
35 has many features for tab-completion, object introspection, system shell
35 has many features for tab-completion, object introspection, system shell
36 access, command history retrieval across sessions, and its own special
36 access, command history retrieval across sessions, and its own special
37 command system for adding functionality when working interactively. It
37 command system for adding functionality when working interactively. It
38 tries to be a very efficient environment both for Python code development
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
39 and for exploration of problems using Python objects (in situations like
40 data analysis).
40 data analysis).
41
41
42 2. Serve as an embeddable, ready to use interpreter for your own
42 2. Serve as an embeddable, ready to use interpreter for your own
43 programs. An interactive IPython shell can be started with a single call
43 programs. An interactive IPython shell can be started with a single call
44 from inside another program, providing access to the current namespace.
44 from inside another program, providing access to the current namespace.
45 This can be very useful both for debugging purposes and for situations
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.
46 where a blend of batch-processing and interactive exploration are needed.
47
47
48 3. Offer a flexible framework which can be used as the base
48 3. Offer a flexible framework which can be used as the base
49 environment for working with other systems, with Python as the underlying
49 environment for working with other systems, with Python as the underlying
50 bridge language. Specifically scientific environments like Mathematica,
50 bridge language. Specifically scientific environments like Mathematica,
51 IDL and Matlab inspired its design, but similar ideas can be
51 IDL and Matlab inspired its design, but similar ideas can be
52 useful in many fields.
52 useful in many fields.
53
53
54 4. Allow interactive testing of threaded graphical toolkits. IPython
54 4. Allow interactive testing of threaded graphical toolkits. IPython
55 has support for interactive, non-blocking control of GTK, Qt, WX, GLUT, and
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
56 OS X applications via special threading flags. The normal Python
57 shell can only do this for Tkinter applications.
57 shell can only do this for Tkinter applications.
58
58
59 Main features of the interactive shell
59 Main features of the interactive shell
60 --------------------------------------
60 --------------------------------------
61
61
62 * Dynamic object introspection. One can access docstrings, function
62 * Dynamic object introspection. One can access docstrings, function
63 definition prototypes, source code, source files and other details
63 definition prototypes, source code, source files and other details
64 of any object accessible to the interpreter with a single
64 of any object accessible to the interpreter with a single
65 keystroke (:samp:`?`, and using :samp:`??` provides additional detail).
65 keystroke (:samp:`?`, and using :samp:`??` provides additional detail).
66
66
67 * Searching through modules and namespaces with :samp:`*` wildcards, both
67 * Searching through modules and namespaces with :samp:`*` wildcards, both
68 when using the :samp:`?` system and via the :samp:`%psearch` command.
68 when using the :samp:`?` system and via the :samp:`%psearch` command.
69
69
70 * Completion in the local namespace, by typing :kbd:`TAB` at the prompt.
70 * Completion in the local namespace, by typing :kbd:`TAB` at the prompt.
71 This works for keywords, modules, methods, variables and files in the
71 This works for keywords, modules, methods, variables and files in the
72 current directory. This is supported via the ``prompt_toolkit`` library.
72 current directory. This is supported via the ``prompt_toolkit`` library.
73 Custom completers can be implemented easily for different purposes
73 Custom completers can be implemented easily for different purposes
74 (system commands, magic arguments etc.)
74 (system commands, magic arguments etc.)
75
75
76 * Numbered input/output prompts with command history (persistent
76 * Numbered input/output prompts with command history (persistent
77 across sessions and tied to each profile), full searching in this
77 across sessions and tied to each profile), full searching in this
78 history and caching of all input and output.
78 history and caching of all input and output.
79
79
80 * User-extensible 'magic' commands. A set of commands prefixed with
80 * User-extensible 'magic' commands. A set of commands prefixed with
81 :samp:`%` or :samp:`%%` is available for controlling IPython itself and provides
81 :samp:`%` or :samp:`%%` is available for controlling IPython itself and provides
82 directory control, namespace information and many aliases to
82 directory control, namespace information and many aliases to
83 common system shell commands.
83 common system shell commands.
84
84
85 * Alias facility for defining your own system aliases.
85 * Alias facility for defining your own system aliases.
86
86
87 * Complete system shell access. Lines starting with :samp:`!` are passed
87 * Complete system shell access. Lines starting with :samp:`!` are passed
88 directly to the system shell, and using :samp:`!!` or :samp:`var = !cmd`
88 directly to the system shell, and using :samp:`!!` or :samp:`var = !cmd`
89 captures shell output into python variables for further use.
89 captures shell output into python variables for further use.
90
90
91 * The ability to expand python variables when calling the system shell. In a
91 * The ability to expand python variables when calling the system shell. In a
92 shell command, any python variable prefixed with :samp:`$` is expanded. A
92 shell command, any python variable prefixed with :samp:`$` is expanded. A
93 double :samp:`$$` allows passing a literal :samp:`$` to the shell (for access
93 double :samp:`$$` allows passing a literal :samp:`$` to the shell (for access
94 to shell and environment variables like :envvar:`PATH`).
94 to shell and environment variables like :envvar:`PATH`).
95
95
96 * Filesystem navigation, via a magic :samp:`%cd` command, along with a
96 * Filesystem navigation, via a magic :samp:`%cd` command, along with a
97 persistent bookmark system (using :samp:`%bookmark`) for fast access to
97 persistent bookmark system (using :samp:`%bookmark`) for fast access to
98 frequently visited directories.
98 frequently visited directories.
99
99
100 * A lightweight persistence framework via the :samp:`%store` command, which
100 * A lightweight persistence framework via the :samp:`%store` command, which
101 allows you to save arbitrary Python variables. These get restored
101 allows you to save arbitrary Python variables. These get restored
102 when you run the :samp:`%store -r` command.
102 when you run the :samp:`%store -r` command.
103
103
104 * Automatic indentation and highlighting of code as you type (through the
104 * Automatic indentation and highlighting of code as you type (through the
105 `prompt_toolkit` library).
105 `prompt_toolkit` library).
106
106
107 * Macro system for quickly re-executing multiple lines of previous
107 * Macro system for quickly re-executing multiple lines of previous
108 input with a single name via the :samp:`%macro` command. Macros can be
108 input with a single name via the :samp:`%macro` command. Macros can be
109 stored persistently via :samp:`%store` and edited via :samp:`%edit`.
109 stored persistently via :samp:`%store` and edited via :samp:`%edit`.
110
110
111 * Session logging (you can then later use these logs as code in your
111 * Session logging (you can then later use these logs as code in your
112 programs). Logs can optionally timestamp all input, and also store
112 programs). Logs can optionally timestamp all input, and also store
113 session output (marked as comments, so the log remains valid
113 session output (marked as comments, so the log remains valid
114 Python source code).
114 Python source code).
115
115
116 * Session restoring: logs can be replayed to restore a previous
116 * Session restoring: logs can be replayed to restore a previous
117 session to the state where you left it.
117 session to the state where you left it.
118
118
119 * Verbose and colored exception traceback printouts. Easier to parse
119 * Verbose and colored exception traceback printouts. Easier to parse
120 visually, and in verbose mode they produce a lot of useful
120 visually, and in verbose mode they produce a lot of useful
121 debugging information (basically a terminal version of the cgitb
121 debugging information (basically a terminal version of the cgitb
122 module).
122 module).
123
123
124 * Auto-parentheses via the :samp:`%autocall` command: callable objects can be
124 * Auto-parentheses via the :samp:`%autocall` command: callable objects can be
125 executed without parentheses: :samp:`sin 3` is automatically converted to
125 executed without parentheses: :samp:`sin 3` is automatically converted to
126 :samp:`sin(3)`
126 :samp:`sin(3)`
127
127
128 * Auto-quoting: using :samp:`,`, or :samp:`;` as the first character forces
128 * Auto-quoting: using :samp:`,`, or :samp:`;` as the first character forces
129 auto-quoting of the rest of the line: :samp:`,my_function a b` becomes
129 auto-quoting of the rest of the line: :samp:`,my_function a b` becomes
130 automatically :samp:`my_function("a","b")`, while :samp:`;my_function a b`
130 automatically :samp:`my_function("a","b")`, while :samp:`;my_function a b`
131 becomes :samp:`my_function("a b")`.
131 becomes :samp:`my_function("a b")`.
132
132
133 * Extensible input syntax. You can define filters that pre-process
133 * Extensible input syntax. You can define filters that pre-process
134 user input to simplify input in special situations. This allows
134 user input to simplify input in special situations. This allows
135 for example pasting multi-line code fragments which start with
135 for example pasting multi-line code fragments which start with
136 :samp:`>>>` or :samp:`...` such as those from other python sessions or the
136 :samp:`>>>` or :samp:`...` such as those from other python sessions or the
137 standard Python documentation.
137 standard Python documentation.
138
138
139 * Flexible :ref:`configuration system <config_overview>`. It uses a
139 * Flexible :ref:`configuration system <config_overview>`. It uses a
140 configuration file which allows permanent setting of all command-line
140 configuration file which allows permanent setting of all command-line
141 options, module loading, code and file execution. The system allows
141 options, module loading, code and file execution. The system allows
142 recursive file inclusion, so you can have a base file with defaults and
142 recursive file inclusion, so you can have a base file with defaults and
143 layers which load other customizations for particular projects.
143 layers which load other customizations for particular projects.
144
144
145 * Embeddable. You can call IPython as a python shell inside your own
145 * Embeddable. You can call IPython as a python shell inside your own
146 python programs. This can be used both for debugging code or for
146 python programs. This can be used both for debugging code or for
147 providing interactive abilities to your programs with knowledge
147 providing interactive abilities to your programs with knowledge
148 about the local namespaces (very useful in debugging and data
148 about the local namespaces (very useful in debugging and data
149 analysis situations).
149 analysis situations).
150
150
151 * Easy debugger access. You can set IPython to call up an enhanced version of
151 * Easy debugger access. You can set IPython to call up an enhanced version of
152 the Python debugger (pdb) every time there is an uncaught exception. This
152 the Python debugger (pdb) every time there is an uncaught exception. This
153 drops you inside the code which triggered the exception with all the data
153 drops you inside the code which triggered the exception with all the data
154 live and it is possible to navigate the stack to rapidly isolate the source
154 live and it is possible to navigate the stack to rapidly isolate the source
155 of a bug. The :samp:`%run` magic command (with the :samp:`-d` option) can run
155 of a bug. The :samp:`%run` magic command (with the :samp:`-d` option) can run
156 any script under pdb's control, automatically setting initial breakpoints for
156 any script under pdb's control, automatically setting initial breakpoints for
157 you. This version of pdb has IPython-specific improvements, including
157 you. This version of pdb has IPython-specific improvements, including
158 tab-completion and traceback coloring support. For even easier debugger
158 tab-completion and traceback coloring support. For even easier debugger
159 access, try :samp:`%debug` after seeing an exception.
159 access, try :samp:`%debug` after seeing an exception.
160
160
161 * Profiler support. You can run single statements (similar to
161 * Profiler support. You can run single statements (similar to
162 :samp:`profile.run()`) or complete programs under the profiler's control.
162 :samp:`profile.run()`) or complete programs under the profiler's control.
163 While this is possible with standard cProfile or profile modules,
163 While this is possible with standard cProfile or profile modules,
164 IPython wraps this functionality with magic commands (see :samp:`%prun`
164 IPython wraps this functionality with magic commands (see :samp:`%prun`
165 and :samp:`%run -p`) convenient for rapid interactive work.
165 and :samp:`%run -p`) convenient for rapid interactive work.
166
166
167 * Simple timing information. You can use the :samp:`%timeit` command to get
167 * Simple timing information. You can use the :samp:`%timeit` command to get
168 the execution time of a Python statement or expression. This machinery is
168 the execution time of a Python statement or expression. This machinery is
169 intelligent enough to do more repetitions for commands that finish very
169 intelligent enough to do more repetitions for commands that finish very
170 quickly in order to get a better estimate of their running time.
170 quickly in order to get a better estimate of their running time.
171
171
172 .. sourcecode:: ipython
172 .. sourcecode:: ipython
173
173
174 In [1]: %timeit 1+1
174 In [1]: %timeit 1+1
175 10000000 loops, best of 3: 25.5 ns per loop
175 10000000 loops, best of 3: 25.5 ns per loop
176
176
177 In [2]: %timeit [math.sin(x) for x in range(5000)]
177 In [2]: %timeit [math.sin(x) for x in range(5000)]
178 1000 loops, best of 3: 719 Β΅s per loop
178 1000 loops, best of 3: 719 Β΅s per loop
179
179
180 ..
180 ..
181
181
182 To get the timing information for more than one expression, use the
182 To get the timing information for more than one expression, use the
183 :samp:`%%timeit` cell magic command.
183 :samp:`%%timeit` cell magic command.
184
184
185
185
186 * Doctest support. The special :samp:`%doctest_mode` command toggles a mode
186 * Doctest support. The special :samp:`%doctest_mode` command toggles a mode
187 to use doctest-compatible prompts, so you can use IPython sessions as
187 to use doctest-compatible prompts, so you can use IPython sessions as
188 doctest code. By default, IPython also allows you to paste existing
188 doctest code. By default, IPython also allows you to paste existing
189 doctests, and strips out the leading :samp:`>>>` and :samp:`...` prompts in
189 doctests, and strips out the leading :samp:`>>>` and :samp:`...` prompts in
190 them.
190 them.
191
191
192 .. _ipythonzmq:
192 .. _ipythonzmq:
193
193
194 Decoupled two-process model
194 Decoupled two-process model
195 ==============================
195 ==============================
196
196
197 IPython has abstracted and extended the notion of a traditional
197 IPython has abstracted and extended the notion of a traditional
198 *Read-Evaluate-Print Loop* (REPL) environment by decoupling the *evaluation*
198 *Read-Evaluate-Print Loop* (REPL) environment by decoupling the *evaluation*
199 into its own process. We call this process a **kernel**: it receives execution
199 into its own process. We call this process a **kernel**: it receives execution
200 instructions from clients and communicates the results back to them.
200 instructions from clients and communicates the results back to them.
201
201
202 This decoupling allows us to have several clients connected to the same
202 This decoupling allows us to have several clients connected to the same
203 kernel, and even allows clients and kernels to live on different machines.
203 kernel, and even allows clients and kernels to live on different machines.
204 With the exclusion of the traditional single process terminal-based IPython
204 With the exclusion of the traditional single process terminal-based IPython
205 (what you start if you run ``ipython`` without any subcommands), all
205 (what you start if you run ``ipython`` without any subcommands), all
206 other IPython machinery uses this two-process model. Most of this is now part
206 other IPython machinery uses this two-process model. Most of this is now part
207 of the `Jupyter` project, whis includes ``jupyter console``, ``jupyter
207 of the `Jupyter` project, which includes ``jupyter console``, ``jupyter
208 qtconsole``, and ``jupyter notebook``.
208 qtconsole``, and ``jupyter notebook``.
209
209
210 As an example, this means that when you start ``jupyter qtconsole``, you're
210 As an example, this means that when you start ``jupyter qtconsole``, you're
211 really starting two processes, a kernel and a Qt-based client can send
211 really starting two processes, a kernel and a Qt-based client can send
212 commands to and receive results from that kernel. If there is already a kernel
212 commands to and receive results from that kernel. If there is already a kernel
213 running that you want to connect to, you can pass the ``--existing`` flag
213 running that you want to connect to, you can pass the ``--existing`` flag
214 which will skip initiating a new kernel and connect to the most recent kernel,
214 which will skip initiating a new kernel and connect to the most recent kernel,
215 instead. To connect to a specific kernel once you have several kernels
215 instead. To connect to a specific kernel once you have several kernels
216 running, use the ``%connect_info`` magic to get the unique connection file,
216 running, use the ``%connect_info`` magic to get the unique connection file,
217 which will be something like ``--existing kernel-19732.json`` but with
217 which will be something like ``--existing kernel-19732.json`` but with
218 different numbers which correspond to the Process ID of the kernel.
218 different numbers which correspond to the Process ID of the kernel.
219
219
220 You can read more about using `jupyter qtconsole
220 You can read more about using `jupyter qtconsole
221 <http://jupyter.org/qtconsole/>`_, and
221 <http://jupyter.org/qtconsole/>`_, and
222 `jupyter notebook <http://jupyter-notebook.readthedocs.io/en/latest/>`_. There
222 `jupyter notebook <http://jupyter-notebook.readthedocs.io/en/latest/>`_. There
223 is also a :ref:`message spec <messaging>` which documents the protocol for
223 is also a :ref:`message spec <messaging>` which documents the protocol for
224 communication between kernels
224 communication between kernels
225 and clients.
225 and clients.
226
226
227 .. seealso::
227 .. seealso::
228
228
229 `Frontend/Kernel Model`_ example notebook
229 `Frontend/Kernel Model`_ example notebook
230
230
231
231
232 Interactive parallel computing
232 Interactive parallel computing
233 ==============================
233 ==============================
234
234
235
235
236 This functionality is optional and now part of the `ipyparallel
236 This functionality is optional and now part of the `ipyparallel
237 <http://ipyparallel.readthedocs.io/>`_ project.
237 <http://ipyparallel.readthedocs.io/>`_ project.
238
238
239 Portability and Python requirements
239 Portability and Python requirements
240 -----------------------------------
240 -----------------------------------
241
241
242 Version 6.0+ supports compatibility with Python 3.3 and higher.
242 Version 6.0+ supports compatibility with Python 3.3 and higher.
243 Versions 2.0 to 5.x work with Python 2.7.x releases and Python 3.3 and higher.
243 Versions 2.0 to 5.x work with Python 2.7.x releases and Python 3.3 and higher.
244 Version 1.0 additionally worked with Python 2.6 and 3.2.
244 Version 1.0 additionally worked with Python 2.6 and 3.2.
245 Version 0.12 was the first version to fully support Python 3.
245 Version 0.12 was the first version to fully support Python 3.
246
246
247 IPython is known to work on the following operating systems:
247 IPython is known to work on the following operating systems:
248
248
249 * Linux
249 * Linux
250 * Most other Unix-like OSs (AIX, Solaris, BSD, etc.)
250 * Most other Unix-like OSs (AIX, Solaris, BSD, etc.)
251 * Mac OS X
251 * Mac OS X
252 * Windows (CygWin, XP, Vista, etc.)
252 * Windows (CygWin, XP, Vista, etc.)
253
253
254 See :ref:`here <install_index>` for instructions on how to install IPython.
254 See :ref:`here <install_index>` for instructions on how to install IPython.
255
255
256 .. include:: links.txt
256 .. include:: links.txt
General Comments 0
You need to be logged in to leave comments. Login now