From 59b953c62785e3097370b16367ad5b29aa026bc0 2015-10-07 13:11:31 From: Min RK Date: 2015-10-07 13:11:31 Subject: [PATCH] fix code blocks in python-ipython-diff code-block requires a language --- diff --git a/docs/source/interactive/python-ipython-diff.rst b/docs/source/interactive/python-ipython-diff.rst index 5cf69e3..466eaf5 100644 --- a/docs/source/interactive/python-ipython-diff.rst +++ b/docs/source/interactive/python-ipython-diff.rst @@ -16,46 +16,46 @@ Quick overview: =============== -All the following construct are valid IPython syntax : +All the following construct are valid IPython syntax: -.. code-block:: +.. code-block:: ipython - ? + In [1]: ? -.. code-block:: +.. code-block:: ipython - ?object + In [1]: ?object -.. code-block:: +.. code-block:: ipython - object? + In [1]: object? -.. code-block:: +.. code-block:: ipython - *pattern*? + In [1]: *pattern*? -.. code-block:: +.. code-block:: ipython - %shell like --syntax + In [1]: %shell like --syntax -.. code-block:: +.. code-block:: ipython - !ls + In [1]: !ls -.. code-block:: +.. code-block:: ipython - my_files =! ls ~/ - for i,file in enumerate(my_file): - raw = !echo $file - !echo {files[0].upper()} $raw + In [1]: my_files =! ls ~/ + In [1]: for i,file in enumerate(my_file): + ...: raw = !echo $file + ...: !echo {files[0].upper()} $raw -.. code-block:: +.. code-block:: ipython - %%perl magic --function - @months = ("July", "August", "September"); - print $months[0]; + In [1]: %%perl magic --function + ...: @months = ("July", "August", "September"); + ...: print $months[0]; Each of these construct is compile by IPython into valid python code and will @@ -63,18 +63,15 @@ do most of the time what you expect it will do. Let see each of these example in more detail. - - - Accessing help ============== As IPython is mostly an interactive shell, the question mark is a simple shortcut to get help. A question mark alone will bring up the IPython help: -.. code-block:: +.. code-block:: ipython - In[1]:? + In [1]: ? IPython -- An enhanced Interactive Python ========================================= @@ -95,7 +92,7 @@ shortcut to get help. A question mark alone will bring up the IPython help: A single question mark before, or after an object available in current namespace will show help relative to this object: -.. code-block:: +.. code-block:: ipython In [6]: object? Docstring: The most base type @@ -105,7 +102,7 @@ namespace will show help relative to this object: A double question mark will try to pull out more information about the object, and if possible display the python source code of this object. -.. code-block:: +.. code-block:: ipython In[1]: import collections In[2]: collection.Counter?? @@ -133,7 +130,8 @@ If you are looking for an object, the use of wildcards ``*`` in conjunction with question mark will allow you to search current namespace for object with matching names: -.. code-block:: +.. code-block:: ipython + In [24]: *int*? FloatingPointError int @@ -149,20 +147,20 @@ This is doable through the use of the exclamation mark ``!`` (or bang). This allow to execute simple command when present in beginning of line: -.. code-block:: +.. code-block:: ipython In[1]: !pwd /User/home/ Change directory: -.. code-block:: +.. code-block:: ipython In[1]: !cd /var/etc Or edit file: -.. code-block:: +.. code-block:: ipython In[1]: !mvim myfile.txt @@ -171,7 +169,7 @@ The line after the bang can call any program installed in the underlying shell, and support variable expansion in the form of ``$variable`` or ``{variable}``. The later form of expansion supports arbitrary python expression: -.. code-block:: +.. code-block:: ipython In[1]: file = 'myfile.txt' @@ -185,14 +183,14 @@ in a list-like object (:see:`IPython Slist`) and assign to the left hand side. This allow you for example to put the list of files of the current working directory in a variable: -.. code-block:: +.. code-block:: ipython In[1]: my_files != ls You can combine the different possibilities in for loops, condition, functions...: -.. code-block:: +.. code-block:: ipython my_files =! ls ~/ b = "backup file" @@ -211,14 +209,14 @@ power. Magic function start with a percent sign (``%``) or double percent (``%%` A magic call with a sign percent will act only one line: -.. code-block:: +.. code-block:: ipython In[1]: %xmode Exception reporting mode: Verbose And support assignment: -.. code-block:: +.. code-block:: ipython In [1]: results = %timeit -r1 -n1 -o list(range(1000)) 1 loops, best of 1: 21.1 µs per loop @@ -228,7 +226,7 @@ And support assignment: Magic with two percent sign can spread over multiple lines, but do not support assignment: -.. code-block:: +.. code-block:: ipython In[1]: %%bash ... : echo "My shell is:" $SHELL @@ -246,6 +244,6 @@ Magic with two percent sign can spread over multiple lines, but do not support a Combining it all ---------------- -.. code-block:: +:: - find a snippet that combine all that into one thing ! + find a snippet that combine all that into one thing!