diff options
author | Georg Brandl <georg@python.org> | 2009-01-03 21:26:05 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2009-01-03 21:26:05 (GMT) |
commit | a1c6a1cea5af1d3c7682a8e99b001b0904480e4d (patch) | |
tree | 85461d1ba5237440b36f253b197779190226a294 /Doc/whatsnew/2.6.rst | |
parent | 48310cd3f2e02ced9ae836ccbcb67e9af3097d62 (diff) | |
download | cpython-a1c6a1cea5af1d3c7682a8e99b001b0904480e4d.zip cpython-a1c6a1cea5af1d3c7682a8e99b001b0904480e4d.tar.gz cpython-a1c6a1cea5af1d3c7682a8e99b001b0904480e4d.tar.bz2 |
Merged revisions 68221 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r68221 | georg.brandl | 2009-01-03 22:04:55 +0100 (Sat, 03 Jan 2009) | 2 lines
Remove tabs from the documentation.
........
Diffstat (limited to 'Doc/whatsnew/2.6.rst')
-rw-r--r-- | Doc/whatsnew/2.6.rst | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/Doc/whatsnew/2.6.rst b/Doc/whatsnew/2.6.rst index 750f7db..5ee71f4 100644 --- a/Doc/whatsnew/2.6.rst +++ b/Doc/whatsnew/2.6.rst @@ -590,30 +590,30 @@ multiple of 4. def factorial(queue, N): - "Compute a factorial." - # If N is a multiple of 4, this function will take much longer. - if (N % 4) == 0: - time.sleep(.05 * N/4) + "Compute a factorial." + # If N is a multiple of 4, this function will take much longer. + if (N % 4) == 0: + time.sleep(.05 * N/4) - # Calculate the result - fact = 1L - for i in range(1, N+1): - fact = fact * i + # Calculate the result + fact = 1L + for i in range(1, N+1): + fact = fact * i - # Put the result on the queue - queue.put(fact) + # Put the result on the queue + queue.put(fact) if __name__ == '__main__': - queue = Queue() + queue = Queue() - N = 5 + N = 5 - p = Process(target=factorial, args=(queue, N)) - p.start() - p.join() + p = Process(target=factorial, args=(queue, N)) + p.start() + p.join() - result = queue.get() - print 'Factorial', N, '=', result + result = queue.get() + print 'Factorial', N, '=', result A :class:`Queue` is used to communicate the input parameter *N* and the result. The :class:`Queue` object is stored in a global variable. @@ -634,12 +634,12 @@ across 5 worker processes and retrieve a list of results:: from multiprocessing import Pool def factorial(N, dictionary): - "Compute a factorial." - ... + "Compute a factorial." + ... p = Pool(5) result = p.map(factorial, range(1, 1000, 10)) for v in result: - print v + print v This produces the following output:: @@ -1889,9 +1889,9 @@ changes, or look through the Subversion logs for all the details. ('id', 'name', 'type', 'size') >>> var = var_type(1, 'frequency', 'int', 4) - >>> print var[0], var.id # Equivalent + >>> print var[0], var.id # Equivalent 1 1 - >>> print var[2], var.type # Equivalent + >>> print var[2], var.type # Equivalent int int >>> var._asdict() {'size': 4, 'type': 'int', 'id': 1, 'name': 'frequency'} @@ -2050,8 +2050,8 @@ changes, or look through the Subversion logs for all the details. >>> list(itertools.product([1,2,3], [4,5,6])) [(1, 4), (1, 5), (1, 6), - (2, 4), (2, 5), (2, 6), - (3, 4), (3, 5), (3, 6)] + (2, 4), (2, 5), (2, 6), + (3, 4), (3, 5), (3, 6)] The optional *repeat* keyword argument is used for taking the product of an iterable or a set of iterables with themselves, |