mirror of
https://github.com/python/cpython.git
synced 2025-12-10 02:50:09 +00:00
#15543: reflow paragraphs.
This commit is contained in:
parent
1b00f25bf9
commit
ee0a945ae4
6 changed files with 31 additions and 34 deletions
|
|
@ -878,9 +878,8 @@ are always available. They are listed here in alphabetical order.
|
||||||
single: universal newlines; open() built-in function
|
single: universal newlines; open() built-in function
|
||||||
|
|
||||||
*newline* controls how :term:`universal newlines` mode works (it only
|
*newline* controls how :term:`universal newlines` mode works (it only
|
||||||
applies to text mode).
|
applies to text mode). It can be ``None``, ``''``, ``'\n'``, ``'\r'``, and
|
||||||
It can be ``None``, ``''``, ``'\n'``, ``'\r'``, and ``'\r\n'``. It
|
``'\r\n'``. It works as follows:
|
||||||
works as follows:
|
|
||||||
|
|
||||||
* When reading input from the stream, if *newline* is ``None``, universal
|
* When reading input from the stream, if *newline* is ``None``, universal
|
||||||
newlines mode is enabled. Lines in the input can end in ``'\n'``,
|
newlines mode is enabled. Lines in the input can end in ``'\n'``,
|
||||||
|
|
|
||||||
|
|
@ -196,10 +196,9 @@ are also provided to help in implementing the core ABCs.
|
||||||
|
|
||||||
An abstract method to return the source of a module. It is returned as
|
An abstract method to return the source of a module. It is returned as
|
||||||
a text string using :term:`universal newlines`, translating all
|
a text string using :term:`universal newlines`, translating all
|
||||||
recognized line separators into ``'\n'`` characters.
|
recognized line separators into ``'\n'`` characters. Returns ``None``
|
||||||
Returns ``None`` if no
|
if no source is available (e.g. a built-in module). Raises
|
||||||
source is available (e.g. a built-in module). Raises :exc:`ImportError`
|
:exc:`ImportError` if the loader cannot find the module specified.
|
||||||
if the loader cannot find the module specified.
|
|
||||||
|
|
||||||
.. method:: is_package(fullname)
|
.. method:: is_package(fullname)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -764,13 +764,13 @@ Text I/O
|
||||||
``''``, ``'\n'``, ``'\r'``, and ``'\r\n'``. It works as follows:
|
``''``, ``'\n'``, ``'\r'``, and ``'\r\n'``. It works as follows:
|
||||||
|
|
||||||
* When reading input from the stream, if *newline* is ``None``,
|
* When reading input from the stream, if *newline* is ``None``,
|
||||||
:term:`universal newlines` mode is enabled. Lines in the input can end
|
:term:`universal newlines` mode is enabled. Lines in the input can end in
|
||||||
in ``'\n'``,
|
``'\n'``, ``'\r'``, or ``'\r\n'``, and these are translated into ``'\n'``
|
||||||
``'\r'``, or ``'\r\n'``, and these are translated into ``'\n'`` before
|
before being returned to the caller. If it is ``''``, universal newlines
|
||||||
being returned to the caller. If it is ``''``, universal newlines mode is
|
mode is enabled, but line endings are returned to the caller untranslated.
|
||||||
enabled, but line endings are returned to the caller untranslated. If it
|
If it has any of the other legal values, input lines are only terminated
|
||||||
has any of the other legal values, input lines are only terminated by the
|
by the given string, and the line ending is returned to the caller
|
||||||
given string, and the line ending is returned to the caller untranslated.
|
untranslated.
|
||||||
|
|
||||||
* When writing output to the stream, if *newline* is ``None``, any ``'\n'``
|
* When writing output to the stream, if *newline* is ``None``, any ``'\n'``
|
||||||
characters written are translated to the system default line separator,
|
characters written are translated to the system default line separator,
|
||||||
|
|
|
||||||
|
|
@ -174,13 +174,13 @@ ZipFile Objects
|
||||||
|
|
||||||
.. method:: ZipFile.open(name, mode='r', pwd=None)
|
.. method:: ZipFile.open(name, mode='r', pwd=None)
|
||||||
|
|
||||||
Extract a member from the archive as a file-like object (ZipExtFile). *name* is
|
Extract a member from the archive as a file-like object (ZipExtFile). *name*
|
||||||
the name of the file in the archive, or a :class:`ZipInfo` object. The *mode*
|
is the name of the file in the archive, or a :class:`ZipInfo` object. The
|
||||||
parameter, if included, must be one of the following: ``'r'`` (the default),
|
*mode* parameter, if included, must be one of the following: ``'r'`` (the
|
||||||
``'U'``, or ``'rU'``. Choosing ``'U'`` or ``'rU'`` will enable
|
default), ``'U'``, or ``'rU'``. Choosing ``'U'`` or ``'rU'`` will enable
|
||||||
:term:`universal newlines` support in the read-only object.
|
:term:`universal newlines` support in the read-only object. *pwd* is the
|
||||||
*pwd* is the password used for encrypted files.
|
password used for encrypted files. Calling :meth:`open` on a closed
|
||||||
Calling :meth:`open` on a closed ZipFile will raise a :exc:`RuntimeError`.
|
ZipFile will raise a :exc:`RuntimeError`.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -379,13 +379,12 @@ mark the ends of lines in text files. Unix uses the linefeed (ASCII character
|
||||||
10), MacOS uses the carriage return (ASCII character 13), and Windows uses a
|
10), MacOS uses the carriage return (ASCII character 13), and Windows uses a
|
||||||
two-character sequence of a carriage return plus a newline.
|
two-character sequence of a carriage return plus a newline.
|
||||||
|
|
||||||
Python's file objects can now support end of line conventions other than the one
|
Python's file objects can now support end of line conventions other than the
|
||||||
followed by the platform on which Python is running. Opening a file with the
|
one followed by the platform on which Python is running. Opening a file with
|
||||||
mode ``'U'`` or ``'rU'`` will open a file for reading in
|
the mode ``'U'`` or ``'rU'`` will open a file for reading in :term:`universal
|
||||||
:term:`universal newlines` mode.
|
newlines` mode. All three line ending conventions will be translated to a
|
||||||
All three line ending conventions will be translated to a ``'\n'`` in the
|
``'\n'`` in the strings returned by the various file methods such as
|
||||||
strings returned by the various file methods such as :meth:`read` and
|
:meth:`read` and :meth:`readline`.
|
||||||
:meth:`readline`.
|
|
||||||
|
|
||||||
Universal newline support is also used when importing modules and when executing
|
Universal newline support is also used when importing modules and when executing
|
||||||
a file with the :func:`execfile` function. This means that Python modules can
|
a file with the :func:`execfile` function. This means that Python modules can
|
||||||
|
|
|
||||||
|
|
@ -1343,12 +1343,12 @@ complete list of changes, or look through the SVN logs for all the details.
|
||||||
|
|
||||||
* The :mod:`fileinput` module was made more flexible. Unicode filenames are now
|
* The :mod:`fileinput` module was made more flexible. Unicode filenames are now
|
||||||
supported, and a *mode* parameter that defaults to ``"r"`` was added to the
|
supported, and a *mode* parameter that defaults to ``"r"`` was added to the
|
||||||
:func:`input` function to allow opening files in binary or
|
:func:`input` function to allow opening files in binary or :term:`universal
|
||||||
:term:`universal newlines` mode.
|
newlines` mode. Another new parameter, *openhook*, lets you use a function
|
||||||
Another new parameter, *openhook*, lets you use a function other than
|
other than :func:`open` to open the input files. Once you're iterating over
|
||||||
:func:`open` to open the input files. Once you're iterating over the set of
|
the set of files, the :class:`FileInput` object's new :meth:`fileno` returns
|
||||||
files, the :class:`FileInput` object's new :meth:`fileno` returns the file
|
the file descriptor for the currently opened file. (Contributed by Georg
|
||||||
descriptor for the currently opened file. (Contributed by Georg Brandl.)
|
Brandl.)
|
||||||
|
|
||||||
* In the :mod:`gc` module, the new :func:`get_count` function returns a 3-tuple
|
* In the :mod:`gc` module, the new :func:`get_count` function returns a 3-tuple
|
||||||
containing the current collection counts for the three GC generations. This is
|
containing the current collection counts for the three GC generations. This is
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue