Issue #23921: Standardized documentation whitespace formatting.
Original patch by James Edwards.
diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst
index d0527d6..fd9312b 100644
--- a/Doc/library/argparse.rst
+++ b/Doc/library/argparse.rst
@@ -35,10 +35,10 @@
parser = argparse.ArgumentParser(description='Process some integers.')
parser.add_argument('integers', metavar='N', type=int, nargs='+',
- help='an integer for the accumulator')
+ help='an integer for the accumulator')
parser.add_argument('--sum', dest='accumulate', action='store_const',
- const=sum, default=max,
- help='sum the integers (default: find the max)')
+ const=sum, default=max,
+ help='sum the integers (default: find the max)')
args = parser.parse_args()
print args.accumulate(args.integers)
@@ -463,7 +463,7 @@
arguments they contain. For example::
>>> with open('args.txt', 'w') as fp:
- ... fp.write('-f\nbar')
+ ... fp.write('-f\nbar')
>>> parser = argparse.ArgumentParser(fromfile_prefix_chars='@')
>>> parser.add_argument('-f')
>>> parser.parse_args(['-f', 'foo', '@args.txt'])
@@ -1064,9 +1064,9 @@
>>> parser = argparse.ArgumentParser(prog='frobble')
>>> parser.add_argument('--foo', action='store_true',
- ... help='foo the bars before frobbling')
+ ... help='foo the bars before frobbling')
>>> parser.add_argument('bar', nargs='+',
- ... help='one of the bars to be frobbled')
+ ... help='one of the bars to be frobbled')
>>> parser.parse_args(['-h'])
usage: frobble [-h] [--foo] bar [bar ...]
@@ -1084,7 +1084,7 @@
>>> parser = argparse.ArgumentParser(prog='frobble')
>>> parser.add_argument('bar', nargs='?', type=int, default=42,
- ... help='the bar to %(prog)s (default: %(default)s)')
+ ... help='the bar to %(prog)s (default: %(default)s)')
>>> parser.print_help()
usage: frobble [-h] [bar]
@@ -1417,10 +1417,10 @@
>>> parser = argparse.ArgumentParser()
>>> parser.add_argument(
... 'integers', metavar='int', type=int, choices=xrange(10),
- ... nargs='+', help='an integer in the range 0..9')
+ ... nargs='+', help='an integer in the range 0..9')
>>> parser.add_argument(
... '--sum', dest='accumulate', action='store_const', const=sum,
- ... default=max, help='sum the integers (default: find the max)')
+ ... default=max, help='sum the integers (default: find the max)')
>>> parser.parse_args(['1', '2', '3', '4'])
Namespace(accumulate=<built-in function max>, integers=[1, 2, 3, 4])
>>> parser.parse_args(['1', '2', '3', '4', '--sum'])
diff --git a/Doc/library/asynchat.rst b/Doc/library/asynchat.rst
index 37d001b..1ad02ec 100644
--- a/Doc/library/asynchat.rst
+++ b/Doc/library/asynchat.rst
@@ -228,7 +228,7 @@
self.set_terminator(None)
self.handle_request()
elif not self.handling:
- self.set_terminator(None) # browsers sometimes over-send
+ self.set_terminator(None) # browsers sometimes over-send
self.cgi_data = parse(self.headers, "".join(self.ibuffer))
self.handling = True
self.ibuffer = []
diff --git a/Doc/library/audioop.rst b/Doc/library/audioop.rst
index e747ba1..8261117 100644
--- a/Doc/library/audioop.rst
+++ b/Doc/library/audioop.rst
@@ -269,6 +269,6 @@
# out_test)
prefill = '\0'*(pos+ipos)*2
postfill = '\0'*(len(inputdata)-len(prefill)-len(outputdata))
- outputdata = prefill + audioop.mul(outputdata,2,-factor) + postfill
+ outputdata = prefill + audioop.mul(outputdata, 2, -factor) + postfill
return audioop.add(inputdata, outputdata, 2)
diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst
index cdf4a43..9ac2c02 100644
--- a/Doc/library/collections.rst
+++ b/Doc/library/collections.rst
@@ -838,7 +838,7 @@
in conjuction with sorting to make a sorted dictionary::
>>> # regular unsorted dictionary
- >>> d = {'banana': 3, 'apple':4, 'pear': 1, 'orange': 2}
+ >>> d = {'banana': 3, 'apple': 4, 'pear': 1, 'orange': 2}
>>> # dictionary sorted by key
>>> OrderedDict(sorted(d.items(), key=lambda t: t[0]))
@@ -1002,10 +1002,13 @@
for value in iterable:
if value not in lst:
lst.append(value)
+
def __iter__(self):
return iter(self.elements)
+
def __contains__(self, value):
return value in self.elements
+
def __len__(self):
return len(self.elements)
diff --git a/Doc/library/configparser.rst b/Doc/library/configparser.rst
index 515074a..16bd07a 100644
--- a/Doc/library/configparser.rst
+++ b/Doc/library/configparser.rst
@@ -489,8 +489,8 @@
config.read('example.cfg')
# Set the third, optional argument of get to 1 if you wish to use raw mode.
- print config.get('Section1', 'foo', 0) # -> "Python is fun!"
- print config.get('Section1', 'foo', 1) # -> "%(bar)s is %(baz)s!"
+ print config.get('Section1', 'foo', 0) # -> "Python is fun!"
+ print config.get('Section1', 'foo', 1) # -> "%(bar)s is %(baz)s!"
# The optional fourth argument is a dict with members that will take
# precedence in interpolation.
@@ -506,10 +506,10 @@
config = ConfigParser.SafeConfigParser({'bar': 'Life', 'baz': 'hard'})
config.read('example.cfg')
- print config.get('Section1', 'foo') # -> "Python is fun!"
+ print config.get('Section1', 'foo') # -> "Python is fun!"
config.remove_option('Section1', 'bar')
config.remove_option('Section1', 'baz')
- print config.get('Section1', 'foo') # -> "Life is hard!"
+ print config.get('Section1', 'foo') # -> "Life is hard!"
The function ``opt_move`` below can be used to move options between sections::
diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst
index 8e3020f..e30b006 100644
--- a/Doc/library/ctypes.rst
+++ b/Doc/library/ctypes.rst
@@ -49,11 +49,11 @@
convention::
>>> from ctypes import *
- >>> print windll.kernel32 # doctest: +WINDOWS
+ >>> print windll.kernel32 # doctest: +WINDOWS
<WinDLL 'kernel32', handle ... at ...>
- >>> print cdll.msvcrt # doctest: +WINDOWS
+ >>> print cdll.msvcrt # doctest: +WINDOWS
<CDLL 'msvcrt', handle ... at ...>
- >>> libc = cdll.msvcrt # doctest: +WINDOWS
+ >>> libc = cdll.msvcrt # doctest: +WINDOWS
>>>
Windows appends the usual ``.dll`` file suffix automatically.
@@ -63,10 +63,10 @@
:meth:`LoadLibrary` method of the dll loaders should be used, or you should load
the library by creating an instance of CDLL by calling the constructor::
- >>> cdll.LoadLibrary("libc.so.6") # doctest: +LINUX
+ >>> cdll.LoadLibrary("libc.so.6") # doctest: +LINUX
<CDLL 'libc.so.6', handle ... at ...>
- >>> libc = CDLL("libc.so.6") # doctest: +LINUX
- >>> libc # doctest: +LINUX
+ >>> libc = CDLL("libc.so.6") # doctest: +LINUX
+ >>> libc # doctest: +LINUX
<CDLL 'libc.so.6', handle ... at ...>
>>>
@@ -83,9 +83,9 @@
>>> from ctypes import *
>>> libc.printf
<_FuncPtr object at 0x...>
- >>> print windll.kernel32.GetModuleHandleA # doctest: +WINDOWS
+ >>> print windll.kernel32.GetModuleHandleA # doctest: +WINDOWS
<_FuncPtr object at 0x...>
- >>> print windll.kernel32.MyOwnFunction # doctest: +WINDOWS
+ >>> print windll.kernel32.MyOwnFunction # doctest: +WINDOWS
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "ctypes.py", line 239, in __getattr__
@@ -115,16 +115,16 @@
identifiers, like ``"??2@YAPAXI@Z"``. In this case you have to use
:func:`getattr` to retrieve the function::
- >>> getattr(cdll.msvcrt, "??2@YAPAXI@Z") # doctest: +WINDOWS
+ >>> getattr(cdll.msvcrt, "??2@YAPAXI@Z") # doctest: +WINDOWS
<_FuncPtr object at 0x...>
>>>
On Windows, some dlls export functions not by name but by ordinal. These
functions can be accessed by indexing the dll object with the ordinal number::
- >>> cdll.kernel32[1] # doctest: +WINDOWS
+ >>> cdll.kernel32[1] # doctest: +WINDOWS
<_FuncPtr object at 0x...>
- >>> cdll.kernel32[0] # doctest: +WINDOWS
+ >>> cdll.kernel32[0] # doctest: +WINDOWS
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "ctypes.py", line 310, in __getitem__
@@ -146,9 +146,9 @@
This example calls both functions with a NULL pointer (``None`` should be used
as the NULL pointer)::
- >>> print libc.time(None) # doctest: +SKIP
+ >>> print libc.time(None) # doctest: +SKIP
1150640792
- >>> print hex(windll.kernel32.GetModuleHandleA(None)) # doctest: +WINDOWS
+ >>> print hex(windll.kernel32.GetModuleHandleA(None)) # doctest: +WINDOWS
0x1d000000
>>>
@@ -157,11 +157,11 @@
Windows. It does this by examining the stack after the function returns, so
although an error is raised the function *has* been called::
- >>> windll.kernel32.GetModuleHandleA() # doctest: +WINDOWS
+ >>> windll.kernel32.GetModuleHandleA() # doctest: +WINDOWS
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ValueError: Procedure probably called with not enough arguments (4 bytes missing)
- >>> windll.kernel32.GetModuleHandleA(0, 0) # doctest: +WINDOWS
+ >>> windll.kernel32.GetModuleHandleA(0, 0) # doctest: +WINDOWS
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ValueError: Procedure probably called with too many arguments (4 bytes in excess)
@@ -170,13 +170,13 @@
The same exception is raised when you call an ``stdcall`` function with the
``cdecl`` calling convention, or vice versa::
- >>> cdll.kernel32.GetModuleHandleA(None) # doctest: +WINDOWS
+ >>> cdll.kernel32.GetModuleHandleA(None) # doctest: +WINDOWS
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ValueError: Procedure probably called with not enough arguments (4 bytes missing)
>>>
- >>> windll.msvcrt.printf("spam") # doctest: +WINDOWS
+ >>> windll.msvcrt.printf("spam") # doctest: +WINDOWS
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ValueError: Procedure probably called with too many arguments (4 bytes in excess)
@@ -189,7 +189,7 @@
crashes from general protection faults when functions are called with invalid
argument values::
- >>> windll.kernel32.GetModuleHandleA(32) # doctest: +WINDOWS
+ >>> windll.kernel32.GetModuleHandleA(32) # doctest: +WINDOWS
Traceback (most recent call last):
File "<stdin>", line 1, in ?
WindowsError: exception: access violation reading 0x00000020
@@ -448,9 +448,9 @@
a string pointer and a char, and returns a pointer to a string::
>>> strchr = libc.strchr
- >>> strchr("abcdef", ord("d")) # doctest: +SKIP
+ >>> strchr("abcdef", ord("d")) # doctest: +SKIP
8059983
- >>> strchr.restype = c_char_p # c_char_p is a pointer to a string
+ >>> strchr.restype = c_char_p # c_char_p is a pointer to a string
>>> strchr("abcdef", ord("d"))
'def'
>>> print strchr("abcdef", ord("x"))
@@ -481,17 +481,17 @@
result of this call will be used as the result of your function call. This is
useful to check for error return values and automatically raise an exception::
- >>> GetModuleHandle = windll.kernel32.GetModuleHandleA # doctest: +WINDOWS
+ >>> GetModuleHandle = windll.kernel32.GetModuleHandleA # doctest: +WINDOWS
>>> def ValidHandle(value):
... if value == 0:
... raise WinError()
... return value
...
>>>
- >>> GetModuleHandle.restype = ValidHandle # doctest: +WINDOWS
- >>> GetModuleHandle(None) # doctest: +WINDOWS
+ >>> GetModuleHandle.restype = ValidHandle # doctest: +WINDOWS
+ >>> GetModuleHandle(None) # doctest: +WINDOWS
486539264
- >>> GetModuleHandle("something silly") # doctest: +WINDOWS
+ >>> GetModuleHandle("something silly") # doctest: +WINDOWS
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "<stdin>", line 3, in ValidHandle
@@ -662,12 +662,12 @@
>>> from ctypes import *
>>> class POINT(Structure):
- ... _fields_ = ("x", c_int), ("y", c_int)
+ ... _fields_ = ("x", c_int), ("y", c_int)
...
>>> class MyStruct(Structure):
- ... _fields_ = [("a", c_int),
- ... ("b", c_float),
- ... ("point_array", POINT * 4)]
+ ... _fields_ = [("a", c_int),
+ ... ("b", c_float),
+ ... ("point_array", POINT * 4)]
>>>
>>> print len(MyStruct().point_array)
4
@@ -1028,7 +1028,7 @@
It is funny to see that on linux the sort function seems to work much more
efficiently, it is doing less comparisons::
- >>> qsort(ia, len(ia), sizeof(c_int), cmp_func) # doctest: +LINUX
+ >>> qsort(ia, len(ia), sizeof(c_int), cmp_func) # doctest: +LINUX
py_cmp_func 5 1
py_cmp_func 33 99
py_cmp_func 7 33
@@ -1151,9 +1151,9 @@
hit the NULL entry::
>>> for item in table:
- ... print item.name, item.size
- ... if item.name is None:
- ... break
+ ... print item.name, item.size
+ ... if item.name is None:
+ ... break
...
__hello__ 104
__phello__ -104
diff --git a/Doc/library/getopt.rst b/Doc/library/getopt.rst
index 2dfb102..2d81e5a 100644
--- a/Doc/library/getopt.rst
+++ b/Doc/library/getopt.rst
@@ -129,7 +129,7 @@
opts, args = getopt.getopt(sys.argv[1:], "ho:v", ["help", "output="])
except getopt.GetoptError as err:
# print help information and exit:
- print str(err) # will print something like "option -a not recognized"
+ print str(err) # will print something like "option -a not recognized"
usage()
sys.exit(2)
output = None
diff --git a/Doc/library/htmlparser.rst b/Doc/library/htmlparser.rst
index 2af4d0c..e73ce07 100644
--- a/Doc/library/htmlparser.rst
+++ b/Doc/library/htmlparser.rst
@@ -66,8 +66,10 @@
class MyHTMLParser(HTMLParser):
def handle_starttag(self, tag, attrs):
print "Encountered a start tag:", tag
+
def handle_endtag(self, tag):
print "Encountered an end tag :", tag
+
def handle_data(self, data):
print "Encountered some data :", data
@@ -252,21 +254,27 @@
print "Start tag:", tag
for attr in attrs:
print " attr:", attr
+
def handle_endtag(self, tag):
print "End tag :", tag
+
def handle_data(self, data):
print "Data :", data
+
def handle_comment(self, data):
print "Comment :", data
+
def handle_entityref(self, name):
c = unichr(name2codepoint[name])
print "Named ent:", c
+
def handle_charref(self, name):
if name.startswith('x'):
c = unichr(int(name[1:], 16))
else:
c = unichr(int(name))
print "Num ent :", c
+
def handle_decl(self, data):
print "Decl :", data
@@ -298,7 +306,7 @@
attr: ('type', 'text/css')
Data : #python { color: green }
End tag : style
- >>>
+
>>> parser.feed('<script type="text/javascript">'
... 'alert("<strong>hello!</strong>");</script>')
Start tag: script
diff --git a/Doc/library/locale.rst b/Doc/library/locale.rst
index 8fa1a1b..0b02685 100644
--- a/Doc/library/locale.rst
+++ b/Doc/library/locale.rst
@@ -481,13 +481,13 @@
Example::
>>> import locale
- >>> loc = locale.getlocale() # get current locale
+ >>> loc = locale.getlocale() # get current locale
# use German locale; name might vary with platform
>>> locale.setlocale(locale.LC_ALL, 'de_DE')
- >>> locale.strcoll('f\xe4n', 'foo') # compare a string containing an umlaut
- >>> locale.setlocale(locale.LC_ALL, '') # use user's preferred locale
- >>> locale.setlocale(locale.LC_ALL, 'C') # use default (C) locale
- >>> locale.setlocale(locale.LC_ALL, loc) # restore saved locale
+ >>> locale.strcoll('f\xe4n', 'foo') # compare a string containing an umlaut
+ >>> locale.setlocale(locale.LC_ALL, '') # use user's preferred locale
+ >>> locale.setlocale(locale.LC_ALL, 'C') # use default (C) locale
+ >>> locale.setlocale(locale.LC_ALL, loc) # restore saved locale
Background, details, hints, tips and caveats
diff --git a/Doc/library/mailcap.rst b/Doc/library/mailcap.rst
index b359509..750d085 100644
--- a/Doc/library/mailcap.rst
+++ b/Doc/library/mailcap.rst
@@ -70,7 +70,7 @@
An example usage::
>>> import mailcap
- >>> d=mailcap.getcaps()
+ >>> d = mailcap.getcaps()
>>> mailcap.findmatch(d, 'video/mpeg', filename='tmp1223')
('xmpeg tmp1223', {'view': 'xmpeg %s'})
diff --git a/Doc/library/mmap.rst b/Doc/library/mmap.rst
index ac1963f..0860cac 100644
--- a/Doc/library/mmap.rst
+++ b/Doc/library/mmap.rst
@@ -140,7 +140,7 @@
pid = os.fork()
- if pid == 0: # In a child process
+ if pid == 0: # In a child process
mm.seek(0)
print mm.readline()
diff --git a/Doc/library/multiprocessing.rst b/Doc/library/multiprocessing.rst
index 9413222..82a0201 100644
--- a/Doc/library/multiprocessing.rst
+++ b/Doc/library/multiprocessing.rst
@@ -2352,8 +2352,8 @@
... do something using "lock" ...
if __name__ == '__main__':
- lock = Lock()
- for i in range(10):
+ lock = Lock()
+ for i in range(10):
Process(target=f).start()
should be rewritten as ::
@@ -2364,8 +2364,8 @@
... do something using "l" ...
if __name__ == '__main__':
- lock = Lock()
- for i in range(10):
+ lock = Lock()
+ for i in range(10):
Process(target=f, args=(lock,)).start()
Beware of replacing :data:`sys.stdin` with a "file like object"
diff --git a/Doc/library/optparse.rst b/Doc/library/optparse.rst
index 417b3bb..dfb43a1 100644
--- a/Doc/library/optparse.rst
+++ b/Doc/library/optparse.rst
@@ -27,7 +27,7 @@
Here's an example of using :mod:`optparse` in a simple script::
from optparse import OptionParser
- [...]
+ ...
parser = OptionParser()
parser.add_option("-f", "--file", dest="filename",
help="write report to FILE", metavar="FILE")
@@ -254,7 +254,7 @@
program, create an OptionParser instance::
from optparse import OptionParser
- [...]
+ ...
parser = OptionParser()
Then you can start defining options. The basic syntax is::
@@ -721,7 +721,7 @@
condition::
(options, args) = parser.parse_args()
- [...]
+ ...
if options.a and options.b:
parser.error("options -a and -b are mutually exclusive")
@@ -761,7 +761,7 @@
Here's what :mod:`optparse`\ -based scripts usually look like::
from optparse import OptionParser
- [...]
+ ...
def main():
usage = "usage: %prog [options] arg"
parser = OptionParser(usage)
@@ -771,13 +771,13 @@
action="store_true", dest="verbose")
parser.add_option("-q", "--quiet",
action="store_false", dest="verbose")
- [...]
+ ...
(options, args) = parser.parse_args()
if len(args) != 1:
parser.error("incorrect number of arguments")
if options.verbose:
print "reading %s..." % options.filename
- [...]
+ ...
if __name__ == "__main__":
main()
@@ -1412,7 +1412,7 @@
strings::
parser.add_option("-n", "--dry-run", ...)
- [...]
+ ...
parser.add_option("-n", "--noisy", ...)
(This is particularly true if you've defined your own OptionParser subclass with
@@ -1453,7 +1453,7 @@
Options:
--dry-run do no harm
- [...]
+ ...
-n, --noisy be noisy
It's possible to whittle away the option strings for a previously-added option
@@ -1468,7 +1468,7 @@
accessible, so :mod:`optparse` removes it, leaving this help text::
Options:
- [...]
+ ...
-n, --noisy be noisy
--dry-run new dry-run option
@@ -1704,7 +1704,7 @@
if parser.values.b:
raise OptionValueError("can't use -a after -b")
parser.values.a = 1
- [...]
+ ...
parser.add_option("-a", action="callback", callback=check_order)
parser.add_option("-b", action="store_true", dest="b")
@@ -1722,7 +1722,7 @@
if parser.values.b:
raise OptionValueError("can't use %s after -b" % opt_str)
setattr(parser.values, option.dest, 1)
- [...]
+ ...
parser.add_option("-a", action="callback", callback=check_order, dest='a')
parser.add_option("-b", action="store_true", dest="b")
parser.add_option("-c", action="callback", callback=check_order, dest='c')
@@ -1742,7 +1742,7 @@
raise OptionValueError("%s option invalid when moon is full"
% opt_str)
setattr(parser.values, option.dest, 1)
- [...]
+ ...
parser.add_option("--foo",
action="callback", callback=check_moon, dest="foo")
@@ -1765,7 +1765,7 @@
def store_value(option, opt_str, value, parser):
setattr(parser.values, option.dest, value)
- [...]
+ ...
parser.add_option("--foo",
action="callback", callback=store_value,
type="int", nargs=3, dest="foo")
@@ -1827,9 +1827,9 @@
del parser.rargs[:len(value)]
setattr(parser.values, option.dest, value)
- [...]
- parser.add_option("-c", "--callback", dest="vararg_attr",
- action="callback", callback=vararg_callback)
+ ...
+ parser.add_option("-c", "--callback", dest="vararg_attr",
+ action="callback", callback=vararg_callback)
.. _optparse-extending-optparse:
diff --git a/Doc/library/re.rst b/Doc/library/re.rst
index 55663ec..1239434 100644
--- a/Doc/library/re.rst
+++ b/Doc/library/re.rst
@@ -1120,15 +1120,15 @@
For example::
- >>> re.match("c", "abcdef") # No match
- >>> re.search("c", "abcdef") # Match
+ >>> re.match("c", "abcdef") # No match
+ >>> re.search("c", "abcdef") # Match
<_sre.SRE_Match object at ...>
Regular expressions beginning with ``'^'`` can be used with :func:`search` to
restrict the match at the beginning of the string::
- >>> re.match("c", "abcdef") # No match
- >>> re.search("^c", "abcdef") # No match
+ >>> re.match("c", "abcdef") # No match
+ >>> re.search("^c", "abcdef") # No match
>>> re.search("^a", "abcdef") # Match
<_sre.SRE_Match object at ...>
@@ -1209,9 +1209,9 @@
in each word of a sentence except for the first and last characters::
>>> def repl(m):
- ... inner_word = list(m.group(2))
- ... random.shuffle(inner_word)
- ... return m.group(1) + "".join(inner_word) + m.group(3)
+ ... inner_word = list(m.group(2))
+ ... random.shuffle(inner_word)
+ ... return m.group(1) + "".join(inner_word) + m.group(3)
>>> text = "Professor Abdolmalek, please report your absences promptly."
>>> re.sub(r"(\w)(\w+)(\w)", repl, text)
'Poefsrosr Aealmlobdk, pslaee reorpt your abnseces plmrptoy.'
diff --git a/Doc/library/ssl.rst b/Doc/library/ssl.rst
index fe2325e..9d8d080 100644
--- a/Doc/library/ssl.rst
+++ b/Doc/library/ssl.rst
@@ -1452,7 +1452,7 @@
except ImportError:
pass
else:
- ... # do something that requires SSL support
+ ... # do something that requires SSL support
Client-side operation
^^^^^^^^^^^^^^^^^^^^^
diff --git a/Doc/library/string.rst b/Doc/library/string.rst
index 260cd0a..55733b9 100644
--- a/Doc/library/string.rst
+++ b/Doc/library/string.rst
@@ -262,12 +262,12 @@
Some simple format string examples::
- "First, thou shalt count to {0}" # References first positional argument
- "Bring me a {}" # Implicitly references the first positional argument
- "From {} to {}" # Same as "From {0} to {1}"
- "My quest is {name}" # References keyword argument 'name'
- "Weight in tons {0.weight}" # 'weight' attribute of first positional arg
- "Units destroyed: {players[0]}" # First element of keyword argument 'players'.
+ "First, thou shalt count to {0}" # References first positional argument
+ "Bring me a {}" # Implicitly references the first positional argument
+ "From {} to {}" # Same as "From {0} to {1}"
+ "My quest is {name}" # References keyword argument 'name'
+ "Weight in tons {0.weight}" # 'weight' attribute of first positional arg
+ "Units destroyed: {players[0]}" # First element of keyword argument 'players'.
The *conversion* field causes a type coercion before formatting. Normally, the
job of formatting a value is done by the :meth:`__format__` method of the value
diff --git a/Doc/library/threading.rst b/Doc/library/threading.rst
index ccb922b..e16f78c 100644
--- a/Doc/library/threading.rst
+++ b/Doc/library/threading.rst
@@ -778,7 +778,7 @@
print "hello, world"
t = Timer(30.0, hello)
- t.start() # after 30 seconds, "hello, world" will be printed
+ t.start() # after 30 seconds, "hello, world" will be printed
.. class:: Timer(interval, function, args=[], kwargs={})
diff --git a/Doc/library/unittest.rst b/Doc/library/unittest.rst
index cacbb3c..64a1834 100644
--- a/Doc/library/unittest.rst
+++ b/Doc/library/unittest.rst
@@ -115,19 +115,19 @@
class TestStringMethods(unittest.TestCase):
- def test_upper(self):
- self.assertEqual('foo'.upper(), 'FOO')
+ def test_upper(self):
+ self.assertEqual('foo'.upper(), 'FOO')
- def test_isupper(self):
- self.assertTrue('FOO'.isupper())
- self.assertFalse('Foo'.isupper())
+ def test_isupper(self):
+ self.assertTrue('FOO'.isupper())
+ self.assertFalse('Foo'.isupper())
- def test_split(self):
- s = 'hello world'
- self.assertEqual(s.split(), ['hello', 'world'])
- # check that s.split fails when the separator is not a string
- with self.assertRaises(TypeError):
- s.split(2)
+ def test_split(self):
+ s = 'hello world'
+ self.assertEqual(s.split(), ['hello', 'world'])
+ # check that s.split fails when the separator is not a string
+ with self.assertRaises(TypeError):
+ s.split(2)
if __name__ == '__main__':
unittest.main()
diff --git a/Doc/library/wsgiref.rst b/Doc/library/wsgiref.rst
index ea33c94..e755d18 100644
--- a/Doc/library/wsgiref.rst
+++ b/Doc/library/wsgiref.rst
@@ -418,8 +418,8 @@
# Our callable object which is intentionally not compliant to the
# standard, so the validator is going to break
def simple_app(environ, start_response):
- status = '200 OK' # HTTP Status
- headers = [('Content-type', 'text/plain')] # HTTP Headers
+ status = '200 OK' # HTTP Status
+ headers = [('Content-type', 'text/plain')] # HTTP Headers
start_response(status, headers)
# This is going to break because we need to return a list, and
@@ -714,8 +714,8 @@
# is a dictionary containing CGI-style envrironment variables and the
# second variable is the callable object (see PEP 333).
def hello_world_app(environ, start_response):
- status = '200 OK' # HTTP Status
- headers = [('Content-type', 'text/plain')] # HTTP Headers
+ status = '200 OK' # HTTP Status
+ headers = [('Content-type', 'text/plain')] # HTTP Headers
start_response(status, headers)
# The returned object is going to be printed
diff --git a/Doc/library/xml.dom.minidom.rst b/Doc/library/xml.dom.minidom.rst
index afff1c6..b6d46fc 100644
--- a/Doc/library/xml.dom.minidom.rst
+++ b/Doc/library/xml.dom.minidom.rst
@@ -33,10 +33,10 @@
from xml.dom.minidom import parse, parseString
- dom1 = parse('c:\\temp\\mydata.xml') # parse an XML file by name
+ dom1 = parse('c:\\temp\\mydata.xml') # parse an XML file by name
datasource = open('c:\\temp\\mydata.xml')
- dom2 = parse(datasource) # parse an open file
+ dom2 = parse(datasource) # parse an open file
dom3 = parseString('<myxml>Some data<empty/> some more data</myxml>')
diff --git a/Doc/library/xml.etree.elementtree.rst b/Doc/library/xml.etree.elementtree.rst
index 15325c2..20cfc4c 100644
--- a/Doc/library/xml.etree.elementtree.rst
+++ b/Doc/library/xml.etree.elementtree.rst
@@ -129,7 +129,7 @@
It also has children nodes over which we can iterate::
>>> for child in root:
- ... print child.tag, child.attrib
+ ... print child.tag, child.attrib
...
country {'name': 'Liechtenstein'}
country {'name': 'Singapore'}
@@ -148,7 +148,7 @@
:meth:`Element.iter`::
>>> for neighbor in root.iter('neighbor'):
- ... print neighbor.attrib
+ ... print neighbor.attrib
...
{'name': 'Austria', 'direction': 'E'}
{'name': 'Switzerland', 'direction': 'W'}
@@ -162,9 +162,9 @@
content. :meth:`Element.get` accesses the element's attributes::
>>> for country in root.findall('country'):
- ... rank = country.find('rank').text
- ... name = country.get('name')
- ... print name, rank
+ ... rank = country.find('rank').text
+ ... name = country.get('name')
+ ... print name, rank
...
Liechtenstein 1
Singapore 4
@@ -188,9 +188,9 @@
attribute to the rank element::
>>> for rank in root.iter('rank'):
- ... new_rank = int(rank.text) + 1
- ... rank.text = str(new_rank)
- ... rank.set('updated', 'yes')
+ ... new_rank = int(rank.text) + 1
+ ... rank.text = str(new_rank)
+ ... rank.set('updated', 'yes')
...
>>> tree.write('output.xml')
@@ -226,9 +226,9 @@
remove all countries with a rank higher than 50::
>>> for country in root.findall('country'):
- ... rank = int(country.find('rank').text)
- ... if rank > 50:
- ... root.remove(country)
+ ... rank = int(country.find('rank').text)
+ ... if rank > 50:
+ ... root.remove(country)
...
>>> tree.write('output.xml')
@@ -887,6 +887,7 @@
[<Element 'a' at 0xb77ec2ac>, <Element 'a' at 0xb77ec1cc>]
>>> for i in links: # Iterates through all found links
... i.attrib["target"] = "blank"
+ ...
>>> tree.write("output.xhtml")
.. _elementtree-qname-objects:
diff --git a/Doc/library/xmlrpclib.rst b/Doc/library/xmlrpclib.rst
index 4603f8b..07ed124 100644
--- a/Doc/library/xmlrpclib.rst
+++ b/Doc/library/xmlrpclib.rst
@@ -235,7 +235,7 @@
from SimpleXMLRPCServer import SimpleXMLRPCServer
def is_even(n):
- return n%2 == 0
+ return n % 2 == 0
server = SimpleXMLRPCServer(("localhost", 8000))
print "Listening on port 8000..."
@@ -392,7 +392,7 @@
# A marshalling error is going to occur because we're returning a
# complex number
- def add(x,y):
+ def add(x, y):
return x+y+0j
server = SimpleXMLRPCServer(("localhost", 8000))
@@ -590,12 +590,15 @@
class ProxiedTransport(xmlrpclib.Transport):
def set_proxy(self, proxy):
self.proxy = proxy
+
def make_connection(self, host):
self.realhost = host
h = httplib.HTTPConnection(self.proxy)
return h
+
def send_request(self, connection, handler, request_body):
connection.putrequest("POST", 'http://%s%s' % (self.realhost, handler))
+
def send_host(self, connection, host):
connection.putheader('Host', self.realhost)