diff options
-rw-r--r-- | Doc/tutorial/classes.rst | 2 | ||||
-rw-r--r-- | Doc/tutorial/controlflow.rst | 8 | ||||
-rw-r--r-- | Doc/tutorial/datastructures.rst | 10 | ||||
-rw-r--r-- | Doc/tutorial/inputoutput.rst | 4 | ||||
-rw-r--r-- | Doc/tutorial/introduction.rst | 9 | ||||
-rw-r--r-- | Doc/tutorial/modules.rst | 4 | ||||
-rw-r--r-- | Doc/tutorial/stdlib2.rst | 2 |
7 files changed, 20 insertions, 19 deletions
diff --git a/Doc/tutorial/classes.rst b/Doc/tutorial/classes.rst index 0c4580a..93e77cc 100644 --- a/Doc/tutorial/classes.rst +++ b/Doc/tutorial/classes.rst @@ -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'] diff --git a/Doc/tutorial/controlflow.rst b/Doc/tutorial/controlflow.rst index ebd531e..ce47164 100644 --- a/Doc/tutorial/controlflow.rst +++ b/Doc/tutorial/controlflow.rst @@ -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, "!") ... diff --git a/Doc/tutorial/datastructures.rst b/Doc/tutorial/datastructures.rst index 20bade5..39523db 100644 --- a/Doc/tutorial/datastructures.rst +++ b/Doc/tutorial/datastructures.rst @@ -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 diff --git a/Doc/tutorial/inputoutput.rst b/Doc/tutorial/inputoutput.rst index a58b92a..7dc9f74 100644 --- a/Doc/tutorial/inputoutput.rst +++ b/Doc/tutorial/inputoutput.rst @@ -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 diff --git a/Doc/tutorial/introduction.rst b/Doc/tutorial/introduction.rst index 0c37f23..1b24588 100644 --- a/Doc/tutorial/introduction.rst +++ b/Doc/tutorial/introduction.rst @@ -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 diff --git a/Doc/tutorial/modules.rst b/Doc/tutorial/modules.rst index cd91376..7e14a19 100644 --- a/Doc/tutorial/modules.rst +++ b/Doc/tutorial/modules.rst @@ -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: diff --git a/Doc/tutorial/stdlib2.rst b/Doc/tutorial/stdlib2.rst index bd1a225..af243f3 100644 --- a/Doc/tutorial/stdlib2.rst +++ b/Doc/tutorial/stdlib2.rst @@ -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() |