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 8856707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:24:57+00:00 2026-06-14T14:24:57+00:00

I recently took over maintaining a website that is written in Python and uses

  • 0

I recently took over maintaining a website that is written in Python and uses web.py. I’ve created a class I would like to import but I’m getting the “TypeError: ‘module’ object is not callable” error. All the .py modules are stored in a directory call “lib”. In the lib directory are the following modules – noun.py, verb.py, context.py, word.py, base.py. Within the lib directory is the –init–.py file. I’m trying to import the noun.py module into the context module. Below is the code in the context.py module that is used to import the other modules.

from lib import verb, word, base

This seems to work fine for importing the verb, word and base modules. But when I add noun to the end of that statement to make it…

from lib import, verb, word, base, noun

I get the “TypeError: ‘module’ object is not callable” error. I’ve also tried…

import noun #Also produces the same error

So I tried the following…

from noun import *

When I import the module this way the error is eliminated but when I reference an attribute of the noun module I get the error “AttributeError: noun instance has no attribute ‘get_stem_used'”. Below is the code from the noun module…

from base import base

class noun:
    wordBase = None
    stemBase = None

    def __init__(self, pId):
        b = base()
        wrdBase = b.get_word_base(pId)
        self.wordBase = wrdBase['base']
        stmBase = b.get_stemBase(pId)
        self.stemBase = stmBase['stem']
        #Code to make sure the module is instantiated correctly and the data is validated

    def get_output(self):
        return self.wordBase

    def get_stem_used(self):
        return self.stemBase

The verb.py module has essentially the same code as the noun.py module. In the context.py module I have the following code…

 n = noun(id)
 base = n.get_output()
 #I print out base to make sure everything is good and it is

 v = verb(id)
 verb = v.get_output()

“n” and “v” are then passed to the word.py module. Within the word.py module is the following code.

if v.get_stem_used == "Some Value":
    #do whatever
elif n.get_stem_used == "Another value":  #This line produces the "attribute error"
    #do something

When I try to access n.get_stem_used I get the “AttributeError: noun instance has no attribute ‘get_stem_used'” error. I’ve done some research and I ran into this url http://effbot.org/zone/import-confusion.htm this leads me to believe that I’m not properly importing the noun module and since I’m not importing the noun module using the following code…it won’t allow me to refer to the elements with the noun class using the dot notation.

from lib import, verb, word, noun

It’s weird to me that adding “noun” to the end of the above statement isn’t working but it seems to properly import all the other modules. I’ve seen that mixing tabs and spaces can cause this error but I’ve checked using my editor that it is properly tabbed. I’ve been working on this for a while so any help is greatly appreciated. Thanks.

Below is what is in the –init–.py

#!/usr/local/bin/python2.5
# -*- coding: utf-8 -*-
  • 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-06-14T14:24:58+00:00Added an answer on June 14, 2026 at 2:24 pm

    It seems that there’s a confusion here between classes and modules. You say you’re doing from lib import noun, and then n = noun(id). This is the source of your error: noun here refers to the noun module, not the noun class inside that module. Java is not Python: classes are separate importable names from their modules, they don’t have to have the same names as the modules they’re in, and you can have more than one class in a module.

    So, you either need to do:

    from lib import noun
    n = noun.noun(id)
    

    or

    from lib.noun import noun
    n = noun(id)
    

    (As an aside, if you used PEP8-compliant names this would be obvious: you’d import noun but instantiate Noun.)

    Other “not-Java” points: there’s no need to have the get_output and get_stem_used methods, just reference wordBase and stemBase directly. But, if you do have those methods, you need to actually call them in your comparisons: if n.get_stem_used() == "Another value" and so on. (Although this is true of Java too, of course – have you been using Ruby or Scala, perhaps?)

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

Sidebar

Related Questions

I recently took over development of a mobile website that uses the Facebook Graph
I recently took over a project that has a pretty dirty database... The table
I have a large infrastructure that is written in Python 2.6, and I recently
I recently took over a project that a colleague was working on and I
I recently took over an iOS project that seems to be crashing whenever I
I recently took over a project that was left stagnate a team member quit
I just recently took over a project because my clients previous web dev disappeared.
I took over an iPhone project recently that was developed prior iOS4. I'm wondering
I recently took over management of a Windows 2003 server. The application log is
Recently I encountered a bug in an application I took over from another developer.

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.