Skip to content

Commit 3c94412

Browse files
committed
Review Changes - Wrap lines v2
now with pre-commit check to remove whitespace
1 parent c8b77ec commit 3c94412

File tree

1 file changed

+53
-44
lines changed

1 file changed

+53
-44
lines changed

Doc/whatsnew/2.6.rst

Lines changed: 53 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,9 @@ The :mod:`threading` module's locks and condition variables also support the
307307
The lock is acquired before the block is executed and always released once the
308308
block is complete.
309309

310-
The :func:`localcontext` function in the :mod:`decimal` module makes it easy
311-
to save and restore the current decimal context, which encapsulates the desired
312-
precision and rounding characteristics for computations::
310+
The :func:`decimal.localcontext` function in the :mod:`decimal` module makes
311+
it easy to save and restore the current decimal context, which encapsulates
312+
the desired precision and rounding characteristics for computations::
313313

314314
from decimal import Decimal, Context, localcontext
315315

@@ -337,12 +337,12 @@ underlying implementation and should keep reading.
337337
A high-level explanation of the context management protocol is:
338338

339339
* The expression is evaluated and should result in an object called a "context
340-
manager". The context manager must have :meth:`~object.__enter__` and :meth:`~object.__exit__`
341-
methods.
340+
manager". The context manager must have :meth:`~object.__enter__` and
341+
:meth:`~object.__exit__` methods.
342342

343-
* The context manager's :meth:`~object.__enter__` method is called. The value returned
344-
is assigned to *VAR*. If no ``as VAR`` clause is present, the value is simply
345-
discarded.
343+
* The context manager's :meth:`~object.__enter__` method is called. The value
344+
returned is assigned to *VAR*. If no ``as VAR`` clause is present, the
345+
value is simply discarded.
346346

347347
* The code in *BLOCK* is executed.
348348

@@ -431,14 +431,15 @@ The contextlib module
431431
The :mod:`contextlib` module provides some functions and a decorator that
432432
are useful when writing objects for use with the ':keyword:`with`' statement.
433433

434-
The decorator is called :func:`~contextlib.contextmanager`, and lets you write a single
435-
generator function instead of defining a new class. The generator should yield
436-
exactly one value. The code up to the :keyword:`yield` will be executed as the
437-
:meth:`~object.__enter__` method, and the value yielded will be the method's return
438-
value that will get bound to the variable in the ':keyword:`with`' statement's
439-
:keyword:`!as` clause, if any. The code after the :keyword:`!yield` will be
440-
executed in the :meth:`~object.__exit__` method. Any exception raised in the block will
441-
be raised by the :keyword:`!yield` statement.
434+
The decorator is called :func:`~contextlib.contextmanager`, and lets you write
435+
a single generator function instead of defining a new class. The generator
436+
should yield exactly one value. The code up to the :keyword:`yield` will be
437+
executed as the :meth:`~object.__enter__` method, and the value yielded will
438+
be the method's return value that will get bound to the variable in the
439+
':keyword:`with`' statement's :keyword:`!as` clause, if any. The code after
440+
the :keyword:`!yield` will be executed in the :meth:`~object.__exit__` method.
441+
Any exception raised in the block will be raised by the :keyword:`!yield`
442+
statement.
442443

443444
Using this decorator, our database example from the previous section
444445
could be written as::
@@ -571,8 +572,9 @@ approach of the module is still similar. The fundamental class
571572
is the :class:`~multiprocessing.Process`, which is passed a callable object and
572573
a collection of arguments. The :meth:`~multiprocessing.Process.start` method
573574
sets the callable running in a subprocess, after which you can call
574-
the :meth:`~multiprocessing.Process.is_alive` method to check whether the subprocess is still running
575-
and the :meth:`~multiprocessing.Process.join` method to wait for the process to exit.
575+
the :meth:`~multiprocessing.Process.is_alive` method to check whether the
576+
subprocess is still running and the :meth:`~multiprocessing.Process.join`
577+
method to wait for the process to exit.
576578

577579
Here's a simple example where the subprocess will calculate a
578580
factorial. The function doing the calculation is written strangely so
@@ -619,13 +621,15 @@ the object to communicate. (If the parent were to change the value of
619621
the global variable, the child's value would be unaffected, and vice
620622
versa.)
621623

622-
Two other classes, :class:`~multiprocessing.pool.Pool` and :class:`~multiprocessing.Manager`, provide
623-
higher-level interfaces. :class:`~multiprocessing.pool.Pool` will create a fixed number of
624-
worker processes, and requests can then be distributed to the workers
625-
by calling :meth:`~multiprocessing.pool.Pool.apply` or :meth:`~multiprocessing.pool.Pool.apply_async` to add a single request,
626-
and :meth:`map` or :meth:`~multiprocessing.pool.Pool.map_async` to add a number of
627-
requests. The following code uses a :class:`~multiprocessing.pool.Pool` to spread requests
628-
across 5 worker processes and retrieve a list of results::
624+
Two other classes, :class:`~multiprocessing.pool.Pool` and
625+
:class:`~multiprocessing.Manager`, provide higher-level interfaces.
626+
:class:`~multiprocessing.pool.Pool` will create a fixed number of worker
627+
processes, and requests can then be distributed to the workers by calling
628+
:meth:`~multiprocessing.pool.Pool.apply` or
629+
:meth:`~multiprocessing.pool.Pool.apply_async` to add a single request, and
630+
:meth:`map` or :meth:`~multiprocessing.pool.Pool.map_async` to add a number of
631+
requests. The following code uses a :class:`~multiprocessing.pool.Pool` to
632+
spread requests across 5 worker processes and retrieve a list of results::
629633

630634
from multiprocessing import Pool
631635

@@ -646,15 +650,18 @@ This produces the following output::
646650
33452526613163807108170062053440751665152000000000
647651
...
648652

649-
The other high-level interface, the :class:`~multiprocessing.Manager` class, creates a
650-
separate server process that can hold master copies of Python data
653+
The other high-level interface, the :class:`~multiprocessing.Manager` class,
654+
creates a separate server process that can hold master copies of Python data
651655
structures. Other processes can then access and modify these data
652656
structures using proxy objects. The following example creates a
653657
shared dictionary by calling the :meth:`dict` method; the worker
654658
processes then insert values into the dictionary. (Locking is not
655659
done for you automatically, which doesn't matter in this example.
656-
:class:`~multiprocessing.Manager`'s methods also include :meth:`~multiprocessing.managers.SyncManager.Lock`, :meth:`~multiprocessing.managers.SyncManager.RLock`,
657-
and :meth:`~multiprocessing.managers.SyncManager.Semaphore` to create shared locks.)
660+
:class:`~multiprocessing.Manager`'s methods also include
661+
:meth:`~multiprocessing.managers.SyncManager.Lock`,
662+
:meth:`~multiprocessing.managers.SyncManager.RLock`,
663+
and :meth:`~multiprocessing.managers.SyncManager.Semaphore` to create
664+
shared locks.)
658665

659666
::
660667

@@ -824,7 +831,7 @@ documentation for a :ref:`complete list <formatstrings>`; here's a sample:
824831
format, followed by a percent sign.
825832
===== ========================================================================
826833

827-
Classes and types can define a :meth:`__format__` method to control how they're
834+
Classes and types can define a ``__format__`` method to control how they're
828835
formatted. It receives a single argument, the format specifier::
829836

830837
def __format__(self, format_spec):
@@ -834,7 +841,7 @@ formatted. It receives a single argument, the format specifier::
834841
return str(self)
835842

836843
There's also a :func:`format` builtin that will format a single
837-
value. It calls the type's :meth:`__format__` method with the
844+
value. It calls the type's ``__format__`` method with the
838845
provided specifier::
839846

840847
>>> format(75.6564, '.2f')
@@ -1029,22 +1036,23 @@ PEP 3116: New I/O Library
10291036

10301037
Python's built-in file objects support a number of methods, but
10311038
file-like objects don't necessarily support all of them. Objects that
1032-
imitate files usually support :meth:`~io.TextIOBase.read` and :meth:`~io.TextIOBase.write`, but they
1033-
may not support :meth:`readline`, for example. Python 3.0 introduces
1034-
a layered I/O library in the :mod:`io` module that separates buffering
1035-
and text-handling features from the fundamental read and write
1036-
operations.
1039+
imitate files usually support :meth:`~io.TextIOBase.read` and
1040+
:meth:`~io.TextIOBase.write`, but they may not support :meth:`readline`,
1041+
for example. Python 3.0 introduces a layered I/O library in the :mod:`io`
1042+
module that separates buffering and text-handling features from the
1043+
fundamental read and write operations.
10371044

10381045
There are three levels of abstract base classes provided by
10391046
the :mod:`io` module:
10401047

10411048
* :class:`~io.RawIOBase` defines raw I/O operations: :meth:`~io.RawIOBase.read`,
1042-
:meth:`~io.RawIOBase.readinto`,
1043-
:meth:`~io.RawIOBase.write`, :meth:`~io.IOBase.seek`, :meth:`~io.IOBase.tell`, :meth:`~io.IOBase.truncate`,
1044-
and :meth:`~io.IOBase.close`.
1049+
:meth:`~io.RawIOBase.readinto`, :meth:`~io.RawIOBase.write`,
1050+
:meth:`~io.IOBase.seek`, :meth:`~io.IOBase.tell`, :meth:`~io.IOBase.truncate`,
1051+
and :meth:`~io.IOBase.close`.
10451052
Most of the methods of this class will often map to a single system call.
1046-
There are also :meth:`~io.IOBase.readable`, :meth:`~io.IOBase.writable`, and :meth:`~io.IOBase.seekable`
1047-
methods for determining what operations a given object will allow.
1053+
There are also :meth:`~io.IOBase.readable`, :meth:`~io.IOBase.writable`,
1054+
and :meth:`~io.IOBase.seekable` methods for determining what operations a
1055+
given object will allow.
10481056

10491057
Python 3.0 has concrete implementations of this class for files and
10501058
sockets, but Python 2.6 hasn't restructured its file and socket objects
@@ -1054,7 +1062,8 @@ the :mod:`io` module:
10541062
buffers data in memory to reduce the number of
10551063
system calls used, making I/O processing more efficient.
10561064
It supports all of the methods of :class:`~io.RawIOBase`,
1057-
and adds a :attr:`~io.BufferedIOBase.raw` attribute holding the underlying raw object.
1065+
and adds a :attr:`~io.BufferedIOBase.raw` attribute holding the underlying
1066+
raw object.
10581067

10591068
There are five concrete classes implementing this ABC.
10601069
:class:`~io.BufferedWriter` and :class:`~io.BufferedReader` are for objects
@@ -1173,8 +1182,8 @@ dictionary-style access. The phrase "dictionary-style" is vague, however.
11731182
It probably means that accessing items with ``obj[1]`` works.
11741183
Does it imply that setting items with ``obj[2] = value`` works?
11751184
Or that the object will have :meth:`!keys`, :meth:`!values`, and :meth:`!items`
1176-
methods? What about the iterative variants such as :meth:`!iterkeys`? :meth:`!copy`
1177-
and :meth:`!update`? Iterating over the object with :func:`!iter`?
1185+
methods? What about the iterative variants such as :meth:`!iterkeys`?
1186+
:meth:`!copy`and :meth:`!update`? Iterating over the object with :func:`!iter`?
11781187

11791188
The Python 2.6 :mod:`collections` module includes a number of
11801189
different ABCs that represent these distinctions. :class:`Iterable`

0 commit comments

Comments
 (0)