Issue #23921: Standardized documentation whitespace formatting.
Original patch by James Edwards.
diff --git a/Doc/tutorial/appendix.rst b/Doc/tutorial/appendix.rst
index 7ab588b..73b7d1b 100644
--- a/Doc/tutorial/appendix.rst
+++ b/Doc/tutorial/appendix.rst
@@ -92,7 +92,7 @@
filename = os.environ.get('PYTHONSTARTUP')
if filename and os.path.isfile(filename):
with open(filename) as fobj:
- startup_file = fobj.read()
+ startup_file = fobj.read()
exec(startup_file)
diff --git a/Doc/tutorial/classes.rst b/Doc/tutorial/classes.rst
index d82adf6..b1f3f00 100644
--- a/Doc/tutorial/classes.rst
+++ b/Doc/tutorial/classes.rst
@@ -210,6 +210,7 @@
class MyClass:
"""A simple example class"""
i = 12345
+
def f(self):
return 'hello world'
@@ -458,8 +459,10 @@
class C:
f = f1
+
def g(self):
return 'hello world'
+
h = g
Now ``f``, ``g`` and ``h`` are all attributes of class :class:`C` that refer to
@@ -473,8 +476,10 @@
class Bag:
def __init__(self):
self.data = []
+
def add(self, x):
self.data.append(x)
+
def addtwice(self, x):
self.add(x)
self.add(x)
@@ -670,7 +675,7 @@
class Employee:
pass
- john = Employee() # Create an empty employee record
+ john = Employee() # Create an empty employee record
# Fill the fields of the record
john.name = 'John Doe'
@@ -796,8 +801,10 @@
def __init__(self, data):
self.data = data
self.index = len(data)
+
def __iter__(self):
return self
+
def next(self):
if self.index == 0:
raise StopIteration
diff --git a/Doc/tutorial/controlflow.rst b/Doc/tutorial/controlflow.rst
index 8ffaf3f..2af60d0 100644
--- a/Doc/tutorial/controlflow.rst
+++ b/Doc/tutorial/controlflow.rst
@@ -284,7 +284,7 @@
It is simple to write a function that returns a list of the numbers of the
Fibonacci series, instead of printing it::
- >>> def fib2(n): # return Fibonacci series up to n
+ >>> def fib2(n): # return Fibonacci series up to n
... """Return a list containing the Fibonacci series up to n."""
... result = []
... a, b = 0, 1
diff --git a/Doc/tutorial/errors.rst b/Doc/tutorial/errors.rst
index 6f77def..f93a544 100644
--- a/Doc/tutorial/errors.rst
+++ b/Doc/tutorial/errors.rst
@@ -180,14 +180,14 @@
attributes to it as desired. ::
>>> try:
- ... raise Exception('spam', 'eggs')
+ ... raise Exception('spam', 'eggs')
... except Exception as inst:
- ... print type(inst) # the exception instance
- ... print inst.args # arguments stored in .args
- ... print inst # __str__ allows args to be printed directly
- ... x, y = inst.args
- ... print 'x =', x
- ... print 'y =', y
+ ... print type(inst) # the exception instance
+ ... print inst.args # arguments stored in .args
+ ... print inst # __str__ allows args to be printed directly
+ ... x, y = inst.args
+ ... print 'x =', x
+ ... print 'y =', y
...
<type 'exceptions.Exception'>
('spam', 'eggs')
diff --git a/Doc/tutorial/inputoutput.rst b/Doc/tutorial/inputoutput.rst
index 6fdc5f0..3e32af2 100644
--- a/Doc/tutorial/inputoutput.rst
+++ b/Doc/tutorial/inputoutput.rst
@@ -326,10 +326,10 @@
>>> f = open('workfile', 'r+')
>>> f.write('0123456789abcdef')
- >>> f.seek(5) # Go to the 6th byte in the file
+ >>> f.seek(5) # Go to the 6th byte in the file
>>> f.read(1)
'5'
- >>> f.seek(-3, 2) # Go to the 3rd byte before the end
+ >>> f.seek(-3, 2) # Go to the 3rd byte before the end
>>> f.read(1)
'd'
diff --git a/Doc/tutorial/introduction.rst b/Doc/tutorial/introduction.rst
index a4fb70c..b7be00e 100644
--- a/Doc/tutorial/introduction.rst
+++ b/Doc/tutorial/introduction.rst
@@ -236,7 +236,7 @@
This feature is particularly useful when you want to break long strings::
>>> text = ('Put several strings within parentheses '
- 'to have them joined together.')
+ ... 'to have them joined together.')
>>> text
'Put several strings within parentheses to have them joined together.'
@@ -280,11 +280,11 @@
Slice indices have useful defaults; an omitted first index defaults to zero, an
omitted second index defaults to the size of the string being sliced. ::
- >>> word[:2] # character from the beginning to position 2 (excluded)
+ >>> word[:2] # character from the beginning to position 2 (excluded)
'Py'
- >>> word[4:] # characters from position 4 (included) to the end
+ >>> word[4:] # characters from position 4 (included) to the end
'on'
- >>> word[-2:] # characters from the second-last (included) to the end
+ >>> word[-2:] # characters from the second-last (included) to the end
'on'
One way to remember how slices work is to think of the indices as pointing
diff --git a/Doc/tutorial/modules.rst b/Doc/tutorial/modules.rst
index f5b8114..7b6fd9c 100644
--- a/Doc/tutorial/modules.rst
+++ b/Doc/tutorial/modules.rst
@@ -33,7 +33,7 @@
print b,
a, b = b, a+b
- def fib2(n): # return Fibonacci series up to n
+ def fib2(n): # return Fibonacci series up to n
result = []
a, b = 0, 1
while b < n:
diff --git a/Doc/tutorial/stdlib.rst b/Doc/tutorial/stdlib.rst
index f6239d6..4dab074 100644
--- a/Doc/tutorial/stdlib.rst
+++ b/Doc/tutorial/stdlib.rst
@@ -283,7 +283,7 @@
with self.assertRaises(TypeError):
average(20, 30, 70)
- unittest.main() # Calling from the command line invokes all tests
+ unittest.main() # Calling from the command line invokes all tests
.. _tut-batteries-included:
diff --git a/Doc/tutorial/stdlib2.rst b/Doc/tutorial/stdlib2.rst
index 65fb093..50b74d1 100644
--- a/Doc/tutorial/stdlib2.rst
+++ b/Doc/tutorial/stdlib2.rst
@@ -178,6 +178,7 @@
threading.Thread.__init__(self)
self.infile = infile
self.outfile = outfile
+
def run(self):
f = zipfile.ZipFile(self.outfile, 'w', zipfile.ZIP_DEFLATED)
f.write(self.infile)