summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2013-03-13 00:27:53 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2013-03-13 00:27:53 (GMT)
commitfe1c471cb17b059d12d4cd293c7be1850206f755 (patch)
tree1f7e0afa772ef638cd18825b82757e41ba4ca875
parent405952f1a89c75d71bf8420b28d4bab1277e2ccd (diff)
parenta142a343e8a01adad81767f125711db80211e008 (diff)
downloadcpython-fe1c471cb17b059d12d4cd293c7be1850206f755.zip
cpython-fe1c471cb17b059d12d4cd293c7be1850206f755.tar.gz
cpython-fe1c471cb17b059d12d4cd293c7be1850206f755.tar.bz2
#17402: merge with 3.3.
-rw-r--r--Doc/library/mmap.rst28
1 files changed, 14 insertions, 14 deletions
diff --git a/Doc/library/mmap.rst b/Doc/library/mmap.rst
index 1a19a7e..1f36cec 100644
--- a/Doc/library/mmap.rst
+++ b/Doc/library/mmap.rst
@@ -106,19 +106,19 @@ To map anonymous memory, -1 should be passed as the fileno along with the length
with open("hello.txt", "r+b") as f:
# memory-map the file, size 0 means whole file
- map = mmap.mmap(f.fileno(), 0)
+ mm = mmap.mmap(f.fileno(), 0)
# read content via standard file methods
- print(map.readline()) # prints b"Hello Python!\n"
+ print(mm.readline()) # prints b"Hello Python!\n"
# read content via slice notation
- print(map[:5]) # prints b"Hello"
+ print(mm[:5]) # prints b"Hello"
# update content using slice notation;
# note that new content must have same size
- map[6:] = b" world!\n"
+ mm[6:] = b" world!\n"
# ... and read again using standard file methods
- map.seek(0)
- print(map.readline()) # prints b"Hello world!\n"
+ mm.seek(0)
+ print(mm.readline()) # prints b"Hello world!\n"
# close the map
- map.close()
+ mm.close()
:class:`mmap` can also be used as a context manager in a :keyword:`with`
@@ -126,8 +126,8 @@ To map anonymous memory, -1 should be passed as the fileno along with the length
import mmap
- with mmap.mmap(-1, 13) as map:
- map.write("Hello world!")
+ with mmap.mmap(-1, 13) as mm:
+ mm.write("Hello world!")
.. versionadded:: 3.2
Context manager support.
@@ -139,16 +139,16 @@ To map anonymous memory, -1 should be passed as the fileno along with the length
import mmap
import os
- map = mmap.mmap(-1, 13)
- map.write(b"Hello world!")
+ mm = mmap.mmap(-1, 13)
+ mm.write(b"Hello world!")
pid = os.fork()
if pid == 0: # In a child process
- map.seek(0)
- print(map.readline())
+ mm.seek(0)
+ print(mm.readline())
- map.close()
+ mm.close()
Memory-mapped file objects support the following methods: