]> granicus.if.org Git - python/commitdiff
Tutorial formatting patch by Robin Stocker.
authorGeorg Brandl <georg@python.org>
Mon, 3 Sep 2007 07:10:24 +0000 (07:10 +0000)
committerGeorg Brandl <georg@python.org>
Mon, 3 Sep 2007 07:10:24 +0000 (07:10 +0000)
Doc/tutorial/classes.rst
Doc/tutorial/controlflow.rst
Doc/tutorial/datastructures.rst
Doc/tutorial/inputoutput.rst
Doc/tutorial/introduction.rst
Doc/tutorial/modules.rst
Doc/tutorial/stdlib2.rst

index 0c4580a9a7dbf86b9c2dcf0f096eea6662bb7054..93e77cce75deed768ec6fb5abdad1638c2b52a89 100644 (file)
@@ -769,7 +769,7 @@ Examples::
    >>> valedictorian = max((student.gpa, student.name) for student in graduates)
 
    >>> data = 'golf'
-   >>> list(data[i] for i in range(len(data)-1,-1,-1))
+   >>> list(data[i] for i in range(len(data)-1, -1, -1))
    ['f', 'l', 'o', 'g']
 
 
index ebd531e7238936dee76fd3871932fa04c9b97578..ce47164300cfc0b17c96fb53e6d77a2f4fd38223 100644 (file)
@@ -210,7 +210,7 @@ boundary::
    ...     """Print a Fibonacci series up to n."""
    ...     a, b = 0, 1
    ...     while b < n:
-   ...         print(b,end=' ')
+   ...         print(b, end=' ')
    ...         a, b = b, a+b
    ...     print()
    ... 
@@ -389,7 +389,7 @@ Functions can also be called using keyword arguments of the form ``keyword =
 value``.  For instance, the following function::
 
    def parrot(voltage, state='a stiff', action='voom', type='Norwegian Blue'):
-       print("-- This parrot wouldn't", action, end= ' ')
+       print("-- This parrot wouldn't", action, end=' ')
        print("if you put", voltage, "volts through it.")
        print("-- Lovely plumage, the", type)
        print("-- It's", state, "!")
@@ -481,7 +481,7 @@ Normally, these ``variadic`` arguments will be last in the list of formal
 parameters, because they scoop up all remaining input arguments that are 
 passed to the function. Any formal parameters which occur after the ``*args``
 parameter are 'keyword-only' arguments, meaning that they can only be used as 
-keywords rather than positional arguments.::
+keywords rather than positional arguments. ::
  
    >>> def concat(*args, sep="/"):
    ...    return sep.join(args)
@@ -513,7 +513,7 @@ In the same fashion, dictionaries can deliver keyword arguments with the ``**``\
 -operator::
 
    >>> def parrot(voltage, state='a stiff', action='voom'):
-   ...     print("-- This parrot wouldn't", action,end=' ')
+   ...     print("-- This parrot wouldn't", action, end=' ')
    ...     print("if you put", voltage, "volts through it.", end=' ')
    ...     print("E's", state, "!")
    ...
index 20bade5b15780d7d9c07b53c8c5ed496807a62ae..39523dbb7a48508d0be2065bfc9c504c008a7096 100644 (file)
@@ -234,7 +234,7 @@ Here we take a list of numbers and return a list of three times each number::
 
 Now we get a little fancier::
 
-   >>> [[x,x**2] for x in vec]
+   >>> [[x, x**2] for x in vec]
    [[2, 4], [4, 16], [6, 36]]
 
 Here we apply a method call to each item in a sequence::
@@ -243,7 +243,7 @@ Here we apply a method call to each item in a sequence::
    >>> [weapon.strip() for weapon in freshfruit]
    ['banana', 'loganberry', 'passion fruit']
 
-Using the if-clause we can filter the stream::
+Using the :keyword:`if` clause we can filter the stream::
 
    >>> [3*x for x in vec if x > 3]
    [12, 18]
@@ -260,7 +260,7 @@ Tuples can often be created without their parentheses, but not here::
    >>> [(x, x**2) for x in vec]
    [(2, 4), (4, 16), (6, 36)]
 
-Here are some nested for's and other fancy behavior::
+Here are some nested for loops and other fancy behavior::
 
    >>> vec1 = [2, 4, 6]
    >>> vec2 = [4, 3, -9]
@@ -273,7 +273,7 @@ Here are some nested for's and other fancy behavior::
 
 List comprehensions can be applied to complex expressions and nested functions::
 
-   >>> [str(round(355/113.0, i)) for i in range(1,6)]
+   >>> [str(round(355/113.0, i)) for i in range(1, 6)]
    ['3.1', '3.14', '3.142', '3.1416', '3.14159']
 
 
@@ -469,7 +469,7 @@ with the :func:`zip` function. ::
 To loop over a sequence in reverse, first specify the sequence in a forward
 direction and then call the :func:`reversed` function. ::
 
-   >>> for i in reversed(range(1,10,2)):
+   >>> for i in reversed(range(1, 10, 2)):
    ...     print(i)
    ...
    9
index a58b92a00882b66f1ec8c52e47e0701bfae1652a..7dc9f745cd22a572a52769d8fb6b351e1fd5a213 100644 (file)
@@ -78,7 +78,7 @@ Some examples::
 Here are two ways to write a table of squares and cubes::
 
    >>> for x in range(1, 11):
-   ...     print(repr(x).rjust(2), repr(x*x).rjust(3),end=' ')
+   ...     print(repr(x).rjust(2), repr(x*x).rjust(3), end=' ')
    ...     # Note use of 'end' on previous line
    ...     print(repr(x*x*x).rjust(4))
    ...
@@ -93,7 +93,7 @@ Here are two ways to write a table of squares and cubes::
     9  81  729
    10 100 1000
 
-   >>> for x in range(1,11):
+   >>> for x in range(1, 11):
    ...     print('%2d %3d %4d' % (x, x*x, x*x*x))
    ... 
     1   1    1
index 0c37f23c9cf586919c572298ad7a77a554d13282..1b24588834c9f075f9530738af26126df93b61ef 100644 (file)
@@ -111,7 +111,7 @@ of ``j`` or ``J``.  Complex numbers with a nonzero real component are written as
 
    >>> 1j * 1J
    (-1+0j)
-   >>> 1j * complex(0,1)
+   >>> 1j * complex(0, 1)
    (-1+0j)
    >>> 3+1j*3
    (3+3j)
@@ -271,8 +271,9 @@ with two literals, not with arbitrary string expressions::
 
 Strings can be subscripted (indexed); like in C, the first character of a string
 has subscript (index) 0.  There is no separate character type; a character is
-simply a string of size one.  As in Icon, substrings can be specified with the
-*slice notation*: two indices separated by a colon. ::
+simply a string of size one.  As in the Icon programming language, substrings
+can be specified with the *slice notation*: two indices separated by a colon.
+::
 
    >>> word[4]
    'A'
@@ -523,7 +524,7 @@ example::
 
 You can add something to the end of the list::
 
-   >>> p[1].append('xtra')    
+   >>> p[1].append('xtra')
    >>> p
    [1, [2, 3, 'xtra'], 4]
    >>> q
index cd91376ee90faa80e32987784b4e1dcade0eed1e..7e14a19dec9ea3e1bfef6477a6a2c60d91c69219 100644 (file)
@@ -224,9 +224,9 @@ Some tips for experts:
   files when :option:`-O` is used) for all modules in a directory.
 
 * If using Python in a parallel processing system with a shared file system,
-  you need to patch python to disable the creation of the compiled files 
+  you need to patch Python to disable the creation of the compiled files 
   because otherwise the multiple Python interpreters will encounter race 
-  conditions in creating them. 
+  conditions in creating them.
 
 
 .. _tut-standardmodules:
index bd1a22582bcc712786d0692c59cd79f0bcd36e75..af243f339f863a849873428b63379b4923955c41 100644 (file)
@@ -184,7 +184,7 @@ tasks in background while the main program continues to run::
            f = zipfile.ZipFile(self.outfile, 'w', zipfile.ZIP_DEFLATED)
            f.write(self.infile)
            f.close()
-           print('Finished background zip of: ', self.infile)
+           print('Finished background zip of:', self.infile)
 
    background = AsyncZip('mydata.txt', 'myarchive.zip')
    background.start()