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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:53:20+00:00 2026-06-12T14:53:20+00:00

I’ve got some code in a module import pygame from pygame.locals import * import

  • 0

I’ve got some code in a module

import pygame
from pygame.locals import *

import reusable

from state import state

class TitleState(state.State):
    def __init__(self):
        #Create data batches
        self.soundbatch = reusable.resourceloader.ResourceBatch(path="data/sound", type="ogg")
        self.imagebatch = reusable.resourceloader.ResourceBatch(path="data/image", type="tga")

        #Reusable stuff
        self.inputengine = reusable.inputengine.InputEngine()
        self.mousehandler = reusable.mousehandler.MouseHandler()

    def update(self):
        pygame.event.pump()

But it gives me the error

Traceback (most recent call last):
  File "C:\Users\Administrator\Desktop\MegaCity\Start.py", line 1, in <module>
    import megacity.megacity
  File "C:\Users\Administrator\Desktop\MegaCity\megacity\megacity.py", line 37, in <module>
    themc = MegaCity()
  File "C:\Users\Administrator\Desktop\MegaCity\megacity\megacity.py", line 25, in __init__
    self.titlestate = titlestate.TitleState()
  File "C:\Users\Administrator\Desktop\MegaCity\state\titlestate.py", line 21, in __init__
    self.inputengine = reusable.inputengine.InputEngine()
AttributeError: 'module' object has no attribute 'inputengine'

However, the directory of reusable certainly has ‘inputengine’ in it:

 Directory of C:\Users\Administrator\Desktop\MegaCity\reusable

10/09/2012  05:29 PM    <DIR>          .
10/09/2012  05:29 PM    <DIR>          ..
10/08/2012  09:34 PM             3,920 inputengine.py
10/09/2012  04:54 PM             1,364 mousehandler.py
10/08/2012  09:42 PM               799 resourceloader.py
10/09/2012  05:32 PM                 2 __init__.py
10/09/2012  05:32 PM    <DIR>          __pycache__

But, when I do from reusable import inputengine it imports inputengine just fine. Also, when in the __init__.py of reusable I put from . import inputengine the code works. Any insight into this?

  • 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-12T14:53:21+00:00Added an answer on June 12, 2026 at 2:53 pm

    This is how it’s supposed to work (not a bug, but a feature).

    You have to include the packagename in your imports with absolute imports, if you don’t want to do that you can use relative imports as you found out (i.e. from . import inputengine).

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

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a view passing on information from a database: def serve_article(request, id): served_article
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

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.