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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:39:04+00:00 2026-06-13T10:39:04+00:00

Quick question… I have a module enemies.py, containing classes like so: class zombie(game_object): zombie

  • 0

Quick question…

I have a module enemies.py, containing classes like so:

class zombie(game_object):
  "zombie"
  pass

In my main python script, I first declare the game_object class, then import enemies

class game_object:
  pass
import enemies

The enemies.py script complains that it can’t find game_object (to inherit from). How do I organize this?

Just a note, I want to be able to write a game.py, import game_mechanics which includes the class definition for a game_object, THEN import enemies which includes a bunch of subclass definitions of game_object.

  • 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-13T10:39:05+00:00Added an answer on June 13, 2026 at 10:39 am

    Each file needs to import the modules it needs. There is no “super-global scope” in which you can import a module to automatically make it available to all other modules. Importing game_mechanics will not make it available in any module other than the one you import it in. If enemies needs access to things defined in game_mechanics, then you have to do import game_mechanics (or import the things you need from game_mechanics) from inside enemies. Example:

    # game_mechanics.py
    class game_object(object):
       pass
    
    # enemies.py
    from game_mechanics import game_object
    class special_object(game_object):
       pass
    

    Importing modules multiple times does not waste extra memory. The module is only loaded once, and when you import it multiple times, you just get multiple references to the same module.

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

Sidebar

Related Questions

Quick question guys, I have this on my view <div class=product_list> @Html.Action(GetProducts, Products) </div>
quick question. In my user database I have 5 separate tables all containing different
quick question on declaring functions. Lets say I have the following code: class a{
Quick question about the built in python list object. Say you have a list
Quick question regarding settimeout, does it execute periodically like setinterval? Say I have a
Quick question, I have the following string which is a coma separated list of
Quick question. If i am trying to clear multiple divs with the same class
Quick question (and sorry if it's already been asked, I have looked but couldn't
Quick question, I am working on a project at work and I would like
quick question that is confusing me. I have NLTK installed and it has been

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.