Show More
@@ -11,6 +11,7 b' Using IPython for interactive work' | |||
|
11 | 11 | reference |
|
12 | 12 | shell |
|
13 | 13 | tips |
|
14 | python-ipython-diff | |
|
14 | 15 | |
|
15 | 16 | .. seealso:: |
|
16 | 17 |
@@ -7,7 +7,7 b' language and what are the specific construct you can do only in IPython.' | |||
|
7 | 7 | |
|
8 | 8 | Unless expressed otherwise all of the construct you will see here will raise a |
|
9 | 9 | ``SyntaxError`` if run in a pure Python shell, or if executing in a Python |
|
10 |
script. |
|
|
10 | script. | |
|
11 | 11 | |
|
12 | 12 | Each of these features are describe more in details in further part of the documentation. |
|
13 | 13 | |
@@ -56,7 +56,7 b' All the following construct are valid IPython syntax:' | |||
|
56 | 56 | In [1]: %%perl magic --function |
|
57 | 57 | ...: @months = ("July", "August", "September"); |
|
58 | 58 | ...: print $months[0]; |
|
59 | ||
|
59 | ||
|
60 | 60 | |
|
61 | 61 | Each of these construct is compile by IPython into valid python code and will |
|
62 | 62 | do most of the time what you expect it will do. Let see each of these example |
@@ -100,7 +100,7 b' namespace will show help relative to this object:' | |||
|
100 | 100 | |
|
101 | 101 | |
|
102 | 102 | A double question mark will try to pull out more information about the object, |
|
103 |
and if possible display the python source code of this object. |
|
|
103 | and if possible display the python source code of this object. | |
|
104 | 104 | |
|
105 | 105 | .. code-block:: ipython |
|
106 | 106 | |
@@ -143,7 +143,7 b' Shell Assignment' | |||
|
143 | 143 | |
|
144 | 144 | |
|
145 | 145 | When doing interactive computing it is common to need to access the underlying shell. |
|
146 |
This is doable through the use of the exclamation mark ``!`` (or bang). |
|
|
146 | This is doable through the use of the exclamation mark ``!`` (or bang). | |
|
147 | 147 | |
|
148 | 148 | This allow to execute simple command when present in beginning of line: |
|
149 | 149 | |
@@ -179,7 +179,7 b' The later form of expansion supports arbitrary python expression:' | |||
|
179 | 179 | The bang can also be present in the right hand side of an assignment, just |
|
180 | 180 | after the equal sign, or separated from it by a white space. In which case the |
|
181 | 181 | standard output of the command after the bang ``!`` will be split out into lines |
|
182 |
in a list-like object (: |
|
|
182 | in a list-like object (:ref:`IPython Slist`) and assign to the left hand side. | |
|
183 | 183 | |
|
184 | 184 | This allow you for example to put the list of files of the current working directory in a variable: |
|
185 | 185 | |
@@ -205,7 +205,7 b' Magics' | |||
|
205 | 205 | Magics function are often present in the form of shell-like syntax, but are |
|
206 | 206 | under the hood python function. The syntax and assignment possibility are |
|
207 | 207 | similar to the one with the bang (``!``) syntax, but with more flexibility and |
|
208 |
power. Magic function start with a percent sign (``%``) or double percent (``%%``). |
|
|
208 | power. Magic function start with a percent sign (``%``) or double percent (``%%``). | |
|
209 | 209 | |
|
210 | 210 | A magic call with a sign percent will act only one line: |
|
211 | 211 |
@@ -19,7 +19,7 b' file and ignore your configuration setup.' | |||
|
19 | 19 | |
|
20 | 20 | Please note that some of the configuration options are not available at |
|
21 | 21 | the command line, simply because they are not practical here. Look into |
|
22 |
your configuration files for details on those. There are separate configuration |
|
|
22 | your configuration files for details on those. There are separate configuration | |
|
23 | 23 | files for each profile, and the files look like :file:`ipython_config.py` or |
|
24 | 24 | :file:`ipython_config_{frontendname}.py`. Profile directories look like |
|
25 | 25 | :file:`profile_{profilename}` and are typically installed in the :envvar:`IPYTHONDIR` directory, |
@@ -95,17 +95,17 b' the same name::' | |||
|
95 | 95 | /home/fperez |
|
96 | 96 | |
|
97 | 97 | The following uses the builtin :magic:`timeit` in cell mode:: |
|
98 | ||
|
98 | ||
|
99 | 99 | In [10]: %%timeit x = range(10000) |
|
100 | 100 | ...: min(x) |
|
101 | 101 | ...: max(x) |
|
102 |
...: |
|
|
102 | ...: | |
|
103 | 103 | 1000 loops, best of 3: 438 us per loop |
|
104 | 104 | |
|
105 | 105 | In this case, ``x = range(10000)`` is called as the line argument, and the |
|
106 | 106 | block with ``min(x)`` and ``max(x)`` is called as the cell body. The |
|
107 | 107 | :magic:`timeit` magic receives both. |
|
108 | ||
|
108 | ||
|
109 | 109 | If you have 'automagic' enabled (as it is by default), you don't need to type in |
|
110 | 110 | the single ``%`` explicitly for line magics; IPython will scan its internal |
|
111 | 111 | list of magic functions and call one if it exists. With automagic on you can |
@@ -116,7 +116,7 b" then just type ``cd mydir`` to go to directory 'mydir'::" | |||
|
116 | 116 | |
|
117 | 117 | Cell magics *always* require an explicit ``%%`` prefix, automagic |
|
118 | 118 | calling only works for line magics. |
|
119 | ||
|
119 | ||
|
120 | 120 | The automagic system has the lowest possible precedence in name searches, so |
|
121 | 121 | you can freely use variables with the same names as magic commands. If a magic |
|
122 | 122 | command is 'shadowed' by a variable, you will need the explicit ``%`` prefix to |
@@ -146,7 +146,7 b' use it:' | |||
|
146 | 146 | /home/fperez/ipython |
|
147 | 147 | |
|
148 | 148 | Line magics, if they return a value, can be assigned to a variable using the syntax |
|
149 |
``l = %sx ls`` (which in this particular case returns the result of `ls` as a python list). |
|
|
149 | ``l = %sx ls`` (which in this particular case returns the result of `ls` as a python list). | |
|
150 | 150 | See :ref:`below <manual_capture>` for more information. |
|
151 | 151 | |
|
152 | 152 | Type ``%magic`` for more information, including a list of all available magic |
@@ -326,9 +326,9 b' You can assign the result of a system command to a Python variable with the' | |||
|
326 | 326 | syntax ``myfiles = !ls``. Similarly, the result of a magic (as long as it returns |
|
327 | 327 | a value) can be assigned to a variable. For example, the syntax ``myfiles = %sx ls`` |
|
328 | 328 | is equivalent to the above system command example (the :magic:`sx` magic runs a shell command |
|
329 |
and captures the output). Each of these gets machine |
|
|
330 |
readable output from stdout (e.g. without colours), and splits on newlines. To |
|
|
331 |
explicitly get this sort of output without assigning to a variable, use two |
|
|
329 | and captures the output). Each of these gets machine | |
|
330 | readable output from stdout (e.g. without colours), and splits on newlines. To | |
|
331 | explicitly get this sort of output without assigning to a variable, use two | |
|
332 | 332 | exclamation marks (``!!ls``) or the :magic:`sx` magic command without an assignment. |
|
333 | 333 | (However, ``!!`` commands cannot be assigned to a variable.) |
|
334 | 334 | |
@@ -340,8 +340,8 b' See :ref:`string_lists` for details.' | |||
|
340 | 340 | IPython also allows you to expand the value of python variables when |
|
341 | 341 | making system calls. Wrap variables or expressions in {braces}:: |
|
342 | 342 | |
|
343 |
In [1]: pyvar = 'Hello world' |
|
|
344 |
In [2]: !echo "A python variable: {pyvar}" |
|
|
343 | In [1]: pyvar = 'Hello world' | |
|
344 | In [2]: !echo "A python variable: {pyvar}" | |
|
345 | 345 | A python variable: Hello world |
|
346 | 346 | In [3]: import math |
|
347 | 347 | In [4]: x = 8 |
@@ -350,7 +350,7 b' making system calls. Wrap variables or expressions in {braces}::' | |||
|
350 | 350 | |
|
351 | 351 | For simple cases, you can alternatively prepend $ to a variable name:: |
|
352 | 352 | |
|
353 |
In [6]: !echo $sys.argv |
|
|
353 | In [6]: !echo $sys.argv | |
|
354 | 354 | [/home/fperez/usr/bin/ipython] |
|
355 | 355 | In [7]: !echo "A system variable: $$HOME" # Use $$ for literal $ |
|
356 | 356 | A system variable: /home/fperez |
@@ -376,7 +376,7 b' replaced by a positional parameter to the call to %parts::' | |||
|
376 | 376 | In [1]: %alias parts echo first %s second %s |
|
377 | 377 | In [2]: parts A B |
|
378 | 378 | first A second B |
|
379 |
In [3]: parts A |
|
|
379 | In [3]: parts A | |
|
380 | 380 | ERROR: Alias <parts> requires 2 arguments, 1 given. |
|
381 | 381 | |
|
382 | 382 | If called with no parameters, :magic:`alias` prints the table of currently |
@@ -420,8 +420,8 b' Input caching system' | |||
|
420 | 420 | -------------------- |
|
421 | 421 | |
|
422 | 422 | IPython offers numbered prompts (In/Out) with input and output caching |
|
423 |
(also referred to as 'input history'). All input is saved and can be |
|
|
424 |
retrieved as variables (besides the usual arrow key recall), in |
|
|
423 | (also referred to as 'input history'). All input is saved and can be | |
|
424 | retrieved as variables (besides the usual arrow key recall), in | |
|
425 | 425 | addition to the :magic:`rep` magic command that brings a history entry |
|
426 | 426 | up for editing on the next command line. |
|
427 | 427 | |
@@ -451,7 +451,7 b' processing). Type %macro? for more details on the macro system.' | |||
|
451 | 451 | A history function :magic:`history` allows you to see any part of your input |
|
452 | 452 | history by printing a range of the _i variables. |
|
453 | 453 | |
|
454 |
You can also search ('grep') through your history by typing |
|
|
454 | You can also search ('grep') through your history by typing | |
|
455 | 455 | ``%hist -g somestring``. This is handy for searching for URLs, IP addresses, |
|
456 | 456 | etc. You can bring history entries listed by '%hist -g' up for editing |
|
457 | 457 | with the %recall command, or run them immediately with :magic:`rerun`. |
@@ -537,8 +537,8 b' will confuse IPython)::' | |||
|
537 | 537 | |
|
538 | 538 | but this will work:: |
|
539 | 539 | |
|
540 |
In [5]: /zip (1,2,3),(4,5,6) |
|
|
541 |
------> zip ((1,2,3),(4,5,6)) |
|
|
540 | In [5]: /zip (1,2,3),(4,5,6) | |
|
541 | ------> zip ((1,2,3),(4,5,6)) | |
|
542 | 542 | Out[5]: [(1, 4), (2, 5), (3, 6)] |
|
543 | 543 | |
|
544 | 544 | IPython tells you that it has altered your command line by displaying |
@@ -648,7 +648,7 b' them separately, for example with different options for data' | |||
|
648 | 648 | presentation. If you close and open the same instance multiple times, |
|
649 | 649 | its prompt counters simply continue from each execution to the next. |
|
650 | 650 | |
|
651 |
Please look at the docstrings in the :mod:`~IPython.frontend.terminal.embed` |
|
|
651 | Please look at the docstrings in the :mod:`~IPython.frontend.terminal.embed` | |
|
652 | 652 | module for more details on the use of this system. |
|
653 | 653 | |
|
654 | 654 | The following sample file illustrating how to use the embedding |
@@ -682,7 +682,7 b' For more information on the use of the pdb debugger, see :ref:`debugger-commands' | |||
|
682 | 682 | in the Python documentation. |
|
683 | 683 | |
|
684 | 684 | IPython extends the debugger with a few useful additions, like coloring of |
|
685 |
tracebacks. The debugger will adopt the color scheme selected for IPython. |
|
|
685 | tracebacks. The debugger will adopt the color scheme selected for IPython. | |
|
686 | 686 | |
|
687 | 687 | The ``where`` command has also been extended to take as argument the number of |
|
688 | 688 | context line to show. This allows to a many line of context on shallow stack trace: |
@@ -697,7 +697,7 b' context line to show. This allows to a many line of context on shallow stack tra' | |||
|
697 | 697 | ...: 6 |
|
698 | 698 | ...: 7 |
|
699 | 699 | ...: |
|
700 | ||
|
700 | ||
|
701 | 701 | In[6]: foo(1) |
|
702 | 702 | # ... |
|
703 | 703 | ipdb> where 8 |
@@ -797,7 +797,7 b' standard Python tutorial::' | |||
|
797 | 797 | In [4]: >>> while b < 10: |
|
798 | 798 | ...: ... print(b) |
|
799 | 799 | ...: ... a, b = b, a+b |
|
800 |
...: |
|
|
800 | ...: | |
|
801 | 801 | 1 |
|
802 | 802 | 1 |
|
803 | 803 | 2 |
@@ -810,7 +810,7 b' And pasting from IPython sessions works equally well::' | |||
|
810 | 810 | In [1]: In [5]: def f(x): |
|
811 | 811 | ...: ...: "A simple function" |
|
812 | 812 | ...: ...: return x**2 |
|
813 |
...: ...: |
|
|
813 | ...: ...: | |
|
814 | 814 | |
|
815 | 815 | In [2]: f(3) |
|
816 | 816 | Out[2]: 9 |
@@ -832,7 +832,7 b' advantages of this are:' | |||
|
832 | 832 | * GUIs can be enabled and disabled dynamically at runtime. |
|
833 | 833 | * The active GUI can be switched dynamically at runtime. |
|
834 | 834 | * In some cases, multiple GUIs can run simultaneously with no problems. |
|
835 |
* There is a developer API in :mod:`IPython.lib.inputhook` for customizing |
|
|
835 | * There is a developer API in :mod:`IPython.lib.inputhook` for customizing | |
|
836 | 836 | all of these things. |
|
837 | 837 | |
|
838 | 838 | For users, enabling GUI event loop integration is simple. You simple use the |
@@ -848,7 +848,7 b' object, do::' | |||
|
848 | 848 | |
|
849 | 849 | %gui wx |
|
850 | 850 | |
|
851 |
You can also start IPython with an event loop set up using the |
|
|
851 | You can also start IPython with an event loop set up using the `--gui` | |
|
852 | 852 | flag:: |
|
853 | 853 | |
|
854 | 854 | $ ipython --gui=qt |
@@ -862,7 +862,7 b' form of a library, these capabilities are exposed in library form in the' | |||
|
862 | 862 | Interested developers should see the module docstrings for more information, |
|
863 | 863 | but there are a few points that should be mentioned here. |
|
864 | 864 | |
|
865 |
First, the ``PyOSInputHook`` approach only works in command line settings |
|
|
865 | First, the ``PyOSInputHook`` approach only works in command line settings | |
|
866 | 866 | where readline is activated. The integration with various eventloops |
|
867 | 867 | is handled somewhat differently (and more simply) when using the standalone |
|
868 | 868 | kernel, as in the qtconsole and notebook. |
@@ -918,7 +918,7 b' neither v2 PyQt nor PySide work.' | |||
|
918 | 918 | Note that this means for ETS 4 to work with PyQt4, ``QT_API`` *must* be set |
|
919 | 919 | to work with IPython's qt integration, because otherwise PyQt4 will be |
|
920 | 920 | loaded in an incompatible mode. |
|
921 | ||
|
921 | ||
|
922 | 922 | It also means that you must *not* have ``QT_API`` set if you want to |
|
923 | 923 | use ``--gui=qt`` with code that requires PyQt4 API v1. |
|
924 | 924 |
@@ -12,7 +12,7 b' GitHub stats for 2015/06/22 - 2015/07/12 (since 3.2)' | |||
|
12 | 12 | These lists are automatically generated, and may be incomplete or contain duplicates. |
|
13 | 13 | |
|
14 | 14 | We closed 1 issue and merged 3 pull requests. |
|
15 | The full list can be seen `on GitHub <https://github.com/ipython/ipython/milestones/3.2.1>`_ | |
|
15 | The full list can be seen `on GitHub <https://github.com/ipython/ipython/milestones/3.2.1>`__ | |
|
16 | 16 | |
|
17 | 17 | The following 5 authors contributed 9 commits. |
|
18 | 18 | |
@@ -31,7 +31,7 b' GitHub stats for 2015/04/03 - 2015/06/21 (since 3.1)' | |||
|
31 | 31 | These lists are automatically generated, and may be incomplete or contain duplicates. |
|
32 | 32 | |
|
33 | 33 | We closed 7 issues and merged 30 pull requests. |
|
34 | The full list can be seen `on GitHub <https://github.com/ipython/ipython/milestones/3.2>`_ | |
|
34 | The full list can be seen `on GitHub <https://github.com/ipython/ipython/milestones/3.2>`__ | |
|
35 | 35 | |
|
36 | 36 | The following 15 authors contributed 74 commits. |
|
37 | 37 |
General Comments 0
You need to be logged in to leave comments.
Login now