Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions Doc/library/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ are always available. They are listed here in alphabetical order.
If the given source is a string, then leading and trailing spaces and tabs
are stripped.

See :func:`ast.literal_eval` for a function that can safely evaluate strings
See :func:`ast.literal_eval` for a function to evaluate strings
with expressions containing only literals.

.. audit-event:: exec code_object eval
Expand Down Expand Up @@ -1373,8 +1373,7 @@ are always available. They are listed here in alphabetical order.
already exists), ``'x'`` for exclusive creation, and ``'a'`` for appending
(which on *some* Unix systems, means that *all* writes append to the end of
the file regardless of the current seek position). In text mode, if
*encoding* is not specified the encoding used is platform-dependent:
:func:`locale.getencoding` is called to get the current locale encoding.
*encoding* is not specified, UTF-8 is used.
(For reading and writing raw bytes use binary mode and leave
*encoding* unspecified.) The available modes are:

Expand Down Expand Up @@ -1404,7 +1403,7 @@ are always available. They are listed here in alphabetical order.
argument) return contents as :class:`bytes` objects without any decoding. In
text mode (the default, or when ``'t'`` is included in the *mode* argument),
the contents of the file are returned as :class:`str`, the bytes having been
first decoded using a platform-dependent encoding or using the specified
first decoded using UTF-8 or using the specified
*encoding* if given.

.. note::
Expand Down Expand Up @@ -1433,9 +1432,8 @@ are always available. They are listed here in alphabetical order.
described above for binary files.

*encoding* is the name of the encoding used to decode or encode the file.
This should only be used in text mode. The default encoding is platform
dependent (whatever :func:`locale.getencoding` returns), but any
:term:`text encoding` supported by Python can be used.
This should only be used in text mode. The default encoding is UTF-8,
but any :term:`text encoding` supported by Python can be used.
See the :mod:`codecs` module for the list of supported encodings.

*errors* is an optional string that specifies how encoding and decoding
Expand Down Expand Up @@ -1549,6 +1547,9 @@ are always available. They are listed here in alphabetical order.
* On Windows, opening a console buffer may return a subclass of
:class:`io.RawIOBase` other than :class:`io.FileIO`.

.. versionchanged:: 3.15
The default encoding is now UTF-8, rather than locale-dependent.

.. versionchanged:: 3.11
The ``'U'`` mode has been removed.

Expand Down Expand Up @@ -1754,7 +1755,7 @@ are always available. They are listed here in alphabetical order.
self.age = age

def __repr__(self):
return f"Person('{self.name}', {self.age})"
return f"Person({self.name!r}, {self.age!r})"


.. function:: reversed(object, /)
Expand Down
Loading