[Python-checkins] cpython (2.7): #17402: avoid shadowing built-in map in mmap examples. Initial patch by Aman

ezio.melotti python-checkins at python.org
Wed Mar 13 01:28:10 CET 2013


http://hg.python.org/cpython/rev/c226133b1493
changeset:   82637:c226133b1493
branch:      2.7
parent:      82633:4a5ad099b176
user:        Ezio Melotti <ezio.melotti at gmail.com>
date:        Wed Mar 13 02:26:11 2013 +0200
summary:
  #17402: avoid shadowing built-in map in mmap examples.  Initial patch by Aman Shah.

files:
  Doc/library/mmap.rst |  24 ++++++++++++------------
  1 files changed, 12 insertions(+), 12 deletions(-)


diff --git a/Doc/library/mmap.rst b/Doc/library/mmap.rst
--- a/Doc/library/mmap.rst
+++ b/Doc/library/mmap.rst
@@ -114,19 +114,19 @@
 
       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 "Hello Python!"
+          print mm.readline()  # prints "Hello Python!"
           # read content via slice notation
-          print map[:5]  # prints "Hello"
+          print mm[:5]  # prints "Hello"
           # update content using slice notation;
           # note that new content must have same size
-          map[6:] = " world!\n"
+          mm[6:] = " world!\n"
           # ... and read again using standard file methods
-          map.seek(0)
-          print map.readline()  # prints "Hello  world!"
+          mm.seek(0)
+          print mm.readline()  # prints "Hello  world!"
           # close the map
-          map.close()
+          mm.close()
 
 
    The next example demonstrates how to create an anonymous map and exchange
@@ -135,16 +135,16 @@
       import mmap
       import os
 
-      map = mmap.mmap(-1, 13)
-      map.write("Hello world!")
+      mm = mmap.mmap(-1, 13)
+      mm.write("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:

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list