diff options
author | Charles-François Natali <neologix@free.fr> | 2012-01-09 21:40:02 (GMT) |
---|---|---|
committer | Charles-François Natali <neologix@free.fr> | 2012-01-09 21:40:02 (GMT) |
commit | dc3044c7043b687f3be97a731d873dc991f5d83b (patch) | |
tree | eb7ae132b0c152c6ad9dcfe3ae63b80cd2acdb4a /Doc/library/io.rst | |
parent | 8a9b9c7d165c55ef368a5d0be539e17ad3f201d4 (diff) | |
download | cpython-dc3044c7043b687f3be97a731d873dc991f5d83b.zip cpython-dc3044c7043b687f3be97a731d873dc991f5d83b.tar.gz cpython-dc3044c7043b687f3be97a731d873dc991f5d83b.tar.bz2 |
Issue #12760: Add a create mode to open(). Patch by David Townshend.
Diffstat (limited to 'Doc/library/io.rst')
-rw-r--r-- | Doc/library/io.rst | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Doc/library/io.rst b/Doc/library/io.rst index 85e8c5b..82969eb 100644 --- a/Doc/library/io.rst +++ b/Doc/library/io.rst @@ -471,10 +471,13 @@ Raw File I/O * an integer representing the number of an existing OS-level file descriptor to which the resulting :class:`FileIO` object will give access. - The *mode* can be ``'r'``, ``'w'`` or ``'a'`` for reading (default), writing, - 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. Add a - ``'+'`` to the mode to allow simultaneous reading and writing. + 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. The :meth:`read` (when called with a positive argument), :meth:`readinto` and :meth:`write` methods on this class will only make one system call. @@ -487,6 +490,7 @@ Raw File I/O .. versionchanged:: 3.3 The *opener* parameter was added. + The ``'x'`` mode was added. In addition to the attributes and methods from :class:`IOBase` and :class:`RawIOBase`, :class:`FileIO` provides the following data |