Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a142a34

Browse files
committed
#17402: merge with 3.2.
2 parents 220391f + 6771462 commit a142a34

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

Doc/library/mmap.rst

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -106,28 +106,28 @@ To map anonymous memory, -1 should be passed as the fileno along with the length
106106

107107
with open("hello.txt", "r+b") as f:
108108
# memory-map the file, size 0 means whole file
109-
map = mmap.mmap(f.fileno(), 0)
109+
mm = mmap.mmap(f.fileno(), 0)
110110
# read content via standard file methods
111-
print(map.readline()) # prints b"Hello Python!\n"
111+
print(mm.readline()) # prints b"Hello Python!\n"
112112
# read content via slice notation
113-
print(map[:5]) # prints b"Hello"
113+
print(mm[:5]) # prints b"Hello"
114114
# update content using slice notation;
115115
# note that new content must have same size
116-
map[6:] = b" world!\n"
116+
mm[6:] = b" world!\n"
117117
# ... and read again using standard file methods
118-
map.seek(0)
119-
print(map.readline()) # prints b"Hello world!\n"
118+
mm.seek(0)
119+
print(mm.readline()) # prints b"Hello world!\n"
120120
# close the map
121-
map.close()
121+
mm.close()
122122

123123

124124
:class:`mmap` can also be used as a context manager in a :keyword:`with`
125125
statement.::
126126

127127
import mmap
128128

129-
with mmap.mmap(-1, 13) as map:
130-
map.write("Hello world!")
129+
with mmap.mmap(-1, 13) as mm:
130+
mm.write("Hello world!")
131131

132132
.. versionadded:: 3.2
133133
Context manager support.
@@ -139,16 +139,16 @@ To map anonymous memory, -1 should be passed as the fileno along with the length
139139
import mmap
140140
import os
141141

142-
map = mmap.mmap(-1, 13)
143-
map.write(b"Hello world!")
142+
mm = mmap.mmap(-1, 13)
143+
mm.write(b"Hello world!")
144144

145145
pid = os.fork()
146146

147147
if pid == 0: # In a child process
148-
map.seek(0)
149-
print(map.readline())
148+
mm.seek(0)
149+
print(mm.readline())
150150

151-
map.close()
151+
mm.close()
152152

153153

154154
Memory-mapped file objects support the following methods:

0 commit comments

Comments
 (0)