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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:44:03+00:00 2026-05-13T23:44:03+00:00

My code worked fine when it was all in one file. Now, I’m splitting

  • 0

My code worked fine when it was all in one file. Now, I’m splitting up classes into different modules. The modules have been given the same name as the classes. Perhaps this is a problem, because MainPage is failing when it is loaded. Does it think that I’m trying to inherit from a module? Can module/class namespace collisions happen?

MainPage.py

import BaseHandler
from models import Item
from Utils import render

class MainPage(BaseHandler):
    def body(self, CSIN=None): #@UnusedVariable
        self.header('Store')
        items = Item.all().order('name').fetch(10)
        render('Views/table.html', self, {'items': items})
        self.footer()

BaseHandler.py

from google.appengine.ext import webapp
from google.appengine.api import users
from Utils import *

# Controller
class BaseHandler(webapp.RequestHandler):
     # ... continues ... 

Failure traceback:

Traceback (most recent call last):
  File "C:\Program Files\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 3180, in _HandleRequest
    self._Dispatch(dispatcher, self.rfile, outfile, env_dict)
  File "C:\Program Files\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 3123, in _Dispatch
    base_env_dict=env_dict)
  File "C:\Program Files\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 515, in Dispatch
    base_env_dict=base_env_dict)
  File "C:\Program Files\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 2382, in Dispatch
    self._module_dict)
  File "C:\Program Files\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 2292, in ExecuteCGI
    reset_modules = exec_script(handler_path, cgi_path, hook)
  File "C:\Program Files\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 2188, in ExecuteOrImportScript
    exec module_code in script_module.__dict__
  File "C:\Users\odp\workspace\Store\src\Main.py", line 5, in <module>
    import MainPage
  File "C:\Program Files\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 1267, in Decorate
    return func(self, *args, **kwargs)
  File "C:\Program Files\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 1917, in load_module
    return self.FindAndLoadModule(submodule, fullname, search_path)
  File "C:\Program Files\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 1267, in Decorate
    return func(self, *args, **kwargs)
  File "C:\Program Files\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 1819, in FindAndLoadModule
    description)
  File "C:\Program Files\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 1267, in Decorate
    return func(self, *args, **kwargs)
  File "C:\Program Files\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 1770, in LoadModuleRestricted
    description)
  File "C:\Users\odp\workspace\Store\src\MainPage.py", line 10, in <module>
    class MainPage(BaseHandler):
TypeError: Error when calling the metaclass bases
    module.__init__() takes at most 2 arguments (3 given)

It appears this can be solved by using

from BaseHandler import BaseHandler

Is it bad style to have the module and class name be the same?

  • 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-13T23:44:04+00:00Added an answer on May 13, 2026 at 11:44 pm

    Yes, module names share the same namespace as everything else, and, yes, Python thinks you are trying to inherit from a module.

    Change:

    class MainPage(BaseHandler):
    

    to:

    class MainPage(BaseHandler.BaseHandler):
    

    and you should be good to go. That way, you’re saying “please inherit from the BaseHandler class in the BaseHandler module”.

    Alternately, you could change:

    import BaseHandler
    

    to:

    from BaseHandler import BaseHandler
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following JQuery code that worked perfect in C#/Asp.net 2.0 to call
I've worked on many projects where I've been given code by others to update.
Until now deploying my Application with macdeployqt worked fine, but after upgrading to Qt
I used to have a jCarousel of image that worked perfectly fine in the
I'm trying to convert some code that worked great in VB, but I can't
When I've worked a bit with my source code, I did my usual thing
Code I have: cell_val = CStr(Nz(fld.value, )) Dim iter As Long For iter =
The following code for a co-worker throws the following error when he tries to
A co worker of mine asked me to review some of my code and
I am working on some code written by a co-worker who no longer works

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.