Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 769357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:19:20+00:00 2026-05-14T18:19:20+00:00

I tried to run the following code from http://docs.python.org/library/mmap.html import mmap # write a

  • 0

I tried to run the following code from http://docs.python.org/library/mmap.html

import mmap

# write a simple example file
with open("hello.txt", "wb") as f:
    f.write("Hello Python!\n")

with open("hello.txt", "r+b") as f:
    # memory-map the file, size 0 means whole file
    map = mmap.mmap(f.fileno(), 0)
    # read content via standard file methods
    print map.readline()  # prints "Hello Python!"
    # read content via slice notation
    print map[:5]  # prints "Hello"
    # update content using slice notation;
    # note that new content must have same size
    map[6:] = " world!\n"
    # ... and read again using standard file methods
    map.seek(0)
    print map.readline()  # prints "Hello  world!"
    # close the map
    map.close()

But, I got an error.

TypeError: 'module' object is not callable

module body in mmap.py at line 9
map = mmap.mmap(f.fileno(), 0)

What’s wrong with this?
I use python 2.6 on Snow Leopard/Mac.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T18:19:21+00:00Added an answer on May 14, 2026 at 6:19 pm

    I think you’re doing something weird calling your module mmap.py, and the import is getting confused and importing the same file instead… Try changing the name to something else (preferably not a standard library module name :p)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to run PhotoStream sample from following link http://android-developers.blogspot.com/2008/09/android-photostream.html But when i
I'm having problems doing the Database example from PhoneGap. http://docs.phonegap.com/phonegap_storage_storage.md.html#openDatabase The Problem is, when
When I run the following Northwind WPF Toolkit Datagrid code from this article ,
The following code utilizes CreateProcess to run commands with environmental variables. Here, it tries
I tried to run the following command and it says there is nothing to
I received the following error when I tried to run a C# WinForms application
Following the README instructions of the jboss-as-kitchensink example , I have tried to run
Following the instructions at the Observer User Guide , I tried to run the
i run nexus-2.0.2 on linux, following nexus referrence, i tried to start up nexus,
I tried to run the directx samples from ..\Windows Mobile 6 SDK\Samples\PocketPC\CPP\win32\directx\d3dm\tutorials on a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.