diff options
author | Georg Brandl <georg@python.org> | 2009-01-03 20:55:06 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2009-01-03 20:55:06 (GMT) |
commit | c62ef8b4d9648c36218cb0142a6395a00c11885e (patch) | |
tree | 74d90ea6215a37553bb1cddfc4c4eddf947958e9 /Doc/tutorial | |
parent | e92818f58c134549c8820073037a1655330bbea1 (diff) | |
download | cpython-c62ef8b4d9648c36218cb0142a6395a00c11885e.zip cpython-c62ef8b4d9648c36218cb0142a6395a00c11885e.tar.gz cpython-c62ef8b4d9648c36218cb0142a6395a00c11885e.tar.bz2 |
Remove trailing whitespace.
Diffstat (limited to 'Doc/tutorial')
-rw-r--r-- | Doc/tutorial/classes.rst | 6 | ||||
-rw-r--r-- | Doc/tutorial/controlflow.rst | 24 | ||||
-rw-r--r-- | Doc/tutorial/datastructures.rst | 12 | ||||
-rw-r--r-- | Doc/tutorial/errors.rst | 12 | ||||
-rw-r--r-- | Doc/tutorial/index.rst | 2 | ||||
-rw-r--r-- | Doc/tutorial/inputoutput.rst | 6 | ||||
-rw-r--r-- | Doc/tutorial/interpreter.rst | 4 | ||||
-rw-r--r-- | Doc/tutorial/introduction.rst | 16 | ||||
-rw-r--r-- | Doc/tutorial/modules.rst | 4 | ||||
-rw-r--r-- | Doc/tutorial/stdlib.rst | 2 | ||||
-rw-r--r-- | Doc/tutorial/whatnow.rst | 2 |
11 files changed, 45 insertions, 45 deletions
diff --git a/Doc/tutorial/classes.rst b/Doc/tutorial/classes.rst index 43f2c6d..48c7bcb 100644 --- a/Doc/tutorial/classes.rst +++ b/Doc/tutorial/classes.rst @@ -250,7 +250,7 @@ are passed on to :meth:`__init__`. For example, :: ... def __init__(self, realpart, imagpart): ... self.r = realpart ... self.i = imagpart - ... + ... >>> x = Complex(3.0, -4.5) >>> x.r, x.i (3.0, -4.5) @@ -481,7 +481,7 @@ Python has two builtin functions that work with inheritance: ``issubclass(unicode, str)`` is ``False`` since :class:`unicode` is not a subclass of :class:`str` (they only share a common ancestor, :class:`basestring`). - + .. _tut-multiple: @@ -743,7 +743,7 @@ easy to create:: f l o - g + g Anything that can be done with generators can also be done with class based iterators as described in the previous section. What makes generators so diff --git a/Doc/tutorial/controlflow.rst b/Doc/tutorial/controlflow.rst index afc19e9..95a6ea4 100644 --- a/Doc/tutorial/controlflow.rst +++ b/Doc/tutorial/controlflow.rst @@ -62,7 +62,7 @@ they appear in the sequence. For example (no pun intended): ... a = ['cat', 'window', 'defenestrate'] >>> for x in a: ... print x, len(x) - ... + ... cat 3 window 6 defenestrate 12 @@ -75,7 +75,7 @@ convenient:: >>> for x in a[:]: # make a slice copy of the entire list ... if len(x) > 6: a.insert(0, x) - ... + ... >>> a ['defenestrate', 'cat', 'window', 'defenestrate'] @@ -110,7 +110,7 @@ To iterate over the indices of a sequence, you can combine :func:`range` and >>> a = ['Mary', 'had', 'a', 'little', 'lamb'] >>> for i in range(len(a)): ... print i, a[i] - ... + ... 0 Mary 1 had 2 a @@ -146,7 +146,7 @@ following loop, which searches for prime numbers:: ... else: ... # loop fell through without finding a factor ... print n, 'is a prime number' - ... + ... 2 is a prime number 3 is a prime number 4 equals 2 * 2 @@ -167,7 +167,7 @@ required syntactically but the program requires no action. For example:: >>> while True: ... pass # Busy-wait for keyboard interrupt (Ctrl+C) - ... + ... This is commonly used for creating minimal classes:: @@ -181,7 +181,7 @@ at a more abstract level. The :keyword:`pass` is silently ignored:: >>> def initlog(*args): ... pass # Remember to implement this! - ... + ... .. _tut-functions: @@ -197,7 +197,7 @@ boundary:: ... while b < n: ... print b, ... a, b = b, a+b - ... + ... >>> # Now call the function we just defined: ... fib(2000) 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 @@ -268,7 +268,7 @@ Fibonacci series, instead of printing it:: ... result.append(b) # see below ... a, b = b, a+b ... return result - ... + ... >>> f100 = fib2(100) # call it >>> f100 # write the result [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] @@ -403,7 +403,7 @@ calls. Here's an example that fails due to this restriction:: >>> def function(a): ... pass - ... + ... >>> function(0, a=0) Traceback (most recent call last): File "<stdin>", line 1, in ? @@ -456,7 +456,7 @@ Arbitrary Argument Lists ------------------------ .. index:: - statement: * + statement: * Finally, the least frequently used option is to specify that a function can be called with an arbitrary number of arguments. These arguments will be wrapped @@ -565,11 +565,11 @@ Here is an example of a multi-line docstring:: >>> def my_function(): ... """Do nothing, but document it. - ... + ... ... No, really, it doesn't do anything. ... """ ... pass - ... + ... >>> print my_function.__doc__ Do nothing, but document it. diff --git a/Doc/tutorial/datastructures.rst b/Doc/tutorial/datastructures.rst index fa71870..f7e7243 100644 --- a/Doc/tutorial/datastructures.rst +++ b/Doc/tutorial/datastructures.rst @@ -214,7 +214,7 @@ and the next item, and so on. For example, :: >>> def sum(seq): ... def add(x,y): return x+y ... return reduce(add, seq, 0) - ... + ... >>> sum(range(1, 11)) 55 >>> sum([]) @@ -281,7 +281,7 @@ If you've got the stomach for it, list comprehensions can be nested. They are a powerful tool but -- like all powerful tools -- they need to be used carefully, if at all. -Consider the following example of a 3x3 matrix held as a list containing three +Consider the following example of a 3x3 matrix held as a list containing three lists, one list per row:: >>> mat = [ @@ -290,7 +290,7 @@ lists, one list per row:: ... [7, 8, 9], ... ] -Now, if you wanted to swap rows and columns, you could use a list +Now, if you wanted to swap rows and columns, you could use a list comprehension:: >>> print [[row[i] for row in mat] for i in [0, 1, 2]] @@ -308,7 +308,7 @@ A more verbose version of this snippet shows the flow explicitly:: print row[i], print -In real world, you should prefer builtin functions to complex flow statements. +In real world, you should prefer builtin functions to complex flow statements. The :func:`zip` function would do a great job for this use case:: >>> zip(*mat) @@ -551,7 +551,7 @@ with the :func:`zip` function. :: >>> answers = ['lancelot', 'the holy grail', 'blue'] >>> for q, a in zip(questions, answers): ... print 'What is your {0}? It is {1}.'.format(q, a) - ... + ... What is your name? It is lancelot. What is your quest? It is the holy grail. What is your favorite color? It is blue. @@ -574,7 +574,7 @@ returns a new sorted list while leaving the source unaltered. :: >>> basket = ['apple', 'orange', 'apple', 'pear', 'orange', 'banana'] >>> for f in sorted(set(basket)): ... print f - ... + ... apple banana orange diff --git a/Doc/tutorial/errors.rst b/Doc/tutorial/errors.rst index 1740396..e1d988c 100644 --- a/Doc/tutorial/errors.rst +++ b/Doc/tutorial/errors.rst @@ -91,7 +91,7 @@ is signalled by raising the :exc:`KeyboardInterrupt` exception. :: ... break ... except ValueError: ... print "Oops! That was no valid number. Try again..." - ... + ... The :keyword:`try` statement works as follows. @@ -199,12 +199,12 @@ indirectly) in the try clause. For example:: >>> def this_fails(): ... x = 1/0 - ... + ... >>> try: ... this_fails() ... except ZeroDivisionError as detail: ... print 'Handling run-time error:', detail - ... + ... Handling run-time error: integer division or modulo by zero @@ -256,12 +256,12 @@ directly or indirectly. For example:: ... self.value = value ... def __str__(self): ... return repr(self.value) - ... + ... >>> try: ... raise MyError(2*2) ... except MyError as e: ... print 'My exception occurred, value:', e.value - ... + ... My exception occurred, value: 4 >>> raise MyError, 'oops!' Traceback (most recent call last): @@ -331,7 +331,7 @@ example:: ... raise KeyboardInterrupt ... finally: ... print 'Goodbye, world!' - ... + ... Goodbye, world! Traceback (most recent call last): File "<stdin>", line 2, in ? diff --git a/Doc/tutorial/index.rst b/Doc/tutorial/index.rst index 3c0d91d..dfc6ac0 100644 --- a/Doc/tutorial/index.rst +++ b/Doc/tutorial/index.rst @@ -1,7 +1,7 @@ .. _tutorial-index: ###################### - The Python Tutorial + The Python Tutorial ###################### :Release: |version| diff --git a/Doc/tutorial/inputoutput.rst b/Doc/tutorial/inputoutput.rst index ef783ae..34d984a 100644 --- a/Doc/tutorial/inputoutput.rst +++ b/Doc/tutorial/inputoutput.rst @@ -87,7 +87,7 @@ Here are two ways to write a table of squares and cubes:: >>> for x in range(1,11): ... print '{0:2d} {1:3d} {2:4d}'.format(x, x*x, x*x*x) - ... + ... 1 1 1 2 4 8 3 9 27 @@ -162,7 +162,7 @@ number of characters wide. This is useful for making tables pretty.:: >>> table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 7678} >>> for name, phone in table.items(): ... print '{0:10} ==> {1:10d}'.format(name, phone) - ... + ... Jack ==> 4098 Dcab ==> 7678 Sjoerd ==> 4127 @@ -330,7 +330,7 @@ beginning of the file as the reference point. :: >>> f = open('/tmp/workfile', 'r+') >>> f.write('0123456789abcdef') >>> f.seek(5) # Go to the 6th byte in the file - >>> f.read(1) + >>> f.read(1) '5' >>> f.seek(-3, 2) # Go to the 3rd byte before the end >>> f.read(1) diff --git a/Doc/tutorial/interpreter.rst b/Doc/tutorial/interpreter.rst index 0ac7ee1..1511584 100644 --- a/Doc/tutorial/interpreter.rst +++ b/Doc/tutorial/interpreter.rst @@ -112,7 +112,7 @@ example, take a look at this :keyword:`if` statement:: >>> the_world_is_flat = 1 >>> if the_world_is_flat: ... print "Be careful not to fall off!" - ... + ... Be careful not to fall off! @@ -180,7 +180,7 @@ It is possible to use encodings different than ASCII in Python source files. The best way to do it is to put one more special comment line right after the ``#!`` line to define the source file encoding:: - # -*- coding: encoding -*- + # -*- coding: encoding -*- With that declaration, all characters in the source file will be treated as diff --git a/Doc/tutorial/introduction.rst b/Doc/tutorial/introduction.rst index 797e531..99e82a3 100644 --- a/Doc/tutorial/introduction.rst +++ b/Doc/tutorial/introduction.rst @@ -84,7 +84,7 @@ error will occur:: >>> # try to access an undefined variable ... n - Traceback (most recent call last): + Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'n' is not defined @@ -219,14 +219,14 @@ Or, strings can be surrounded in a pair of matching triple-quotes: ``"""`` or they will be included in the string. :: print """ - Usage: thingy [OPTIONS] + Usage: thingy [OPTIONS] -h Display this usage message -H hostname Hostname to connect to """ produces the following output:: - Usage: thingy [OPTIONS] + Usage: thingy [OPTIONS] -h Display this usage message -H hostname Hostname to connect to @@ -350,10 +350,10 @@ One way to remember how slices work is to think of the indices as pointing Then the right edge of the last character of a string of *n* characters has index *n*, for example:: - +---+---+---+---+---+ + +---+---+---+---+---+ | H | e | l | p | A | - +---+---+---+---+---+ - 0 1 2 3 4 5 + +---+---+---+---+---+ + 0 1 2 3 4 5 -5 -4 -3 -2 -1 The first row of numbers gives the position of the indices 0...5 in the string; @@ -595,7 +595,7 @@ series as follows:: >>> while b < 10: ... print b ... a, b = b, a+b - ... + ... 1 1 2 @@ -645,7 +645,7 @@ This example introduces several new features. >>> while b < 1000: ... print b, ... a, b = b, a+b - ... + ... 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 Note that the interpreter inserts a newline before it prints the next prompt if diff --git a/Doc/tutorial/modules.rst b/Doc/tutorial/modules.rst index 7a5af4f..f147cea 100644 --- a/Doc/tutorial/modules.rst +++ b/Doc/tutorial/modules.rst @@ -281,7 +281,7 @@ defines. It returns a sorted list of strings:: ['__name__', 'fib', 'fib2'] >>> dir(sys) ['__displayhook__', '__doc__', '__excepthook__', '__name__', '__stderr__', - '__stdin__', '__stdout__', '_getframe', 'api_version', 'argv', + '__stdin__', '__stdout__', '_getframe', 'api_version', 'argv', 'builtin_module_names', 'byteorder', 'callstats', 'copyright', 'displayhook', 'exc_clear', 'exc_info', 'exc_type', 'excepthook', 'exec_prefix', 'executable', 'exit', 'getdefaultencoding', 'getdlopenflags', @@ -314,7 +314,7 @@ want a list of those, they are defined in the standard module 'FloatingPointError', 'FutureWarning', 'IOError', 'ImportError', 'IndentationError', 'IndexError', 'KeyError', 'KeyboardInterrupt', 'LookupError', 'MemoryError', 'NameError', 'None', 'NotImplemented', - 'NotImplementedError', 'OSError', 'OverflowError', + 'NotImplementedError', 'OSError', 'OverflowError', 'PendingDeprecationWarning', 'ReferenceError', 'RuntimeError', 'RuntimeWarning', 'StandardError', 'StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError', 'True', diff --git a/Doc/tutorial/stdlib.rst b/Doc/tutorial/stdlib.rst index 38e0871..8cd5d0a 100644 --- a/Doc/tutorial/stdlib.rst +++ b/Doc/tutorial/stdlib.rst @@ -136,7 +136,7 @@ The :mod:`random` module provides tools for making random selections:: >>> random.random() # random float 0.17970987693706186 >>> random.randrange(6) # random integer chosen from range(6) - 4 + 4 .. _tut-internet-access: diff --git a/Doc/tutorial/whatnow.rst b/Doc/tutorial/whatnow.rst index 43b5e83..157cc9f 100644 --- a/Doc/tutorial/whatnow.rst +++ b/Doc/tutorial/whatnow.rst @@ -63,6 +63,6 @@ solution for your problem. .. Postings figure based on average of last six months activity as reported by www.egroups.com; Jan. 2000 - June 2000: 21272 msgs / 182 - days = 116.9 msgs / day and steadily increasing. (XXX up to date figures?) + days = 116.9 msgs / day and steadily increasing. (XXX up to date figures?) |