Remove trailing whitespace.

This commit is contained in:
Georg Brandl 2009-01-03 20:55:06 +00:00
parent e92818f58c
commit c62ef8b4d9
149 changed files with 771 additions and 771 deletions

View file

@ -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