mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
Issue #12760: Refer to the new 'x' open mode as "exclusive creation" mode.
This commit is contained in:
parent
138f4656e3
commit
d612de10e5
4 changed files with 13 additions and 12 deletions
|
@ -472,12 +472,12 @@ Raw File I/O
|
|||
to which the resulting :class:`FileIO` object will give access.
|
||||
|
||||
The *mode* can be ``'r'``, ``'w'``, ``'x'`` or ``'a'`` for reading
|
||||
(default), writing, creating or appending. The file will be created if it
|
||||
doesn't exist when opened for writing or appending; it will be truncated
|
||||
when opened for writing. :exc:`FileExistsError` will be raised if it already
|
||||
exists when opened for creating. Opening a file for creating implies
|
||||
writing, so this mode behaves in a similar way to ``'w'``. Add a ``'+'`` to
|
||||
the mode to allow simultaneous reading and writing.
|
||||
(default), writing, exclusive creation or appending. The file will be
|
||||
created if it doesn't exist when opened for writing or appending; it will be
|
||||
truncated when opened for writing. :exc:`FileExistsError` will be raised if
|
||||
it already exists when opened for creating. Opening a file for creating
|
||||
implies writing, so this mode behaves in a similar way to ``'w'``. Add a
|
||||
``'+'`` to the mode to allow simultaneous reading and writing.
|
||||
|
||||
The :meth:`read` (when called with a positive argument), :meth:`readinto`
|
||||
and :meth:`write` methods on this class will only make one system call.
|
||||
|
|
|
@ -427,8 +427,9 @@ parameter to control parameters of the secure channel.
|
|||
io
|
||||
--
|
||||
|
||||
The :func:`~io.open` function has a new ``'x'`` mode that can be used to create
|
||||
a new file, and raise a :exc:`FileExistsError` if the file already exists.
|
||||
The :func:`~io.open` function has a new ``'x'`` mode that can be used to
|
||||
exclusively create a new file, and raise a :exc:`FileExistsError` if the file
|
||||
already exists. It is based on the C11 'x' mode to fopen().
|
||||
|
||||
(Contributed by David Townshend in :issue:`12760`)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue