summaryrefslogtreecommitdiff
path: root/Doc/library/mmap.rst
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/library/mmap.rst')
-rw-r--r--Doc/library/mmap.rst20
1 files changed, 19 insertions, 1 deletions
diff --git a/Doc/library/mmap.rst b/Doc/library/mmap.rst
index 5001d4f55e..128bc90259 100644
--- a/Doc/library/mmap.rst
+++ b/Doc/library/mmap.rst
@@ -111,6 +111,18 @@ To map anonymous memory, -1 should be passed as the fileno along with the length
map.close()
+ :class:`mmap` can also be used as a context manager in a :keyword:`with`
+ statement.::
+
+ import mmap
+
+ with mmap.mmap(-1, 13) as map:
+ map.write("Hello world!")
+
+ .. versionadded:: 3.2
+ Context manager support.
+
+
The next example demonstrates how to create an anonymous map and exchange
data between the parent and child processes::
@@ -131,13 +143,19 @@ To map anonymous memory, -1 should be passed as the fileno along with the length
Memory-mapped file objects support the following methods:
-
.. method:: close()
Close the file. Subsequent calls to other methods of the object will
result in an exception being raised.
+ .. attribute:: closed
+
+ True if the file is closed.
+
+ .. versionadded:: 3.2
+
+
.. method:: find(sub[, start[, end]])
Returns the lowest index in the object where the subsequence *sub* is