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

  • Home
  • SEARCH
  • 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 8540425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:35:35+00:00 2026-06-11T11:35:35+00:00

I am writing a game framework. Here is my current file structure: src/ framework/

  • 0

I am writing a game framework. Here is my current file structure:

src/
  framework/
    __init__.py
    util.py
    render.py
    game.py
  pong.py

I want to be able to simply do import game or import render directly from the pong.py file. What’s the best way to accomplish this? Initially the util.py, render.py, game.py modules were in the src folder but I decided to put them into their separate folder for the sake of organization. I am quite new at packaging conventions so I don’t know if this would be the recommended way of doing things.

  • 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-11T11:35:36+00:00Added an answer on June 11, 2026 at 11:35 am

    The best way to do this would be not to do it at all. For exactly the reasons you moved them in the first place – the sake of organization – you’ll want them to be in a separate module. If you want to refer to the module as game in your code, you can do this:

    from framework import game
    
    game.foo()
    

    Generally, when you do import game, you are providing the expectation that game is either a system library or in the folder the script is running at. If that isn’t the case, it will throw people off. If you were to make your framework a system library, you wouldn’t have it as three separate libraries util, game, and render, no? You’d package it in one library – framework – and distribute that, with submodules. Thus you’re really not going to want to do this.

    But, as I know non-answers can be frustrating, if you really want to go ahead you can add the framework folder to sys.path, which python checks whenever you import a module:

    import sys
    sys.path.append("framework")
    
    import game
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a game in Java, and I want the user to be able
I'm writing a game in python with pygame and need to render text onto
I'm writing a game for iPhone, and I want an online leaderboard using mySQL,
I am writing a game in which I want to kick off an event
I'm writing a simple game engine, and I have the EntityComponent.h file: #ifndef Psycho2D_Core_EntityComponent_
I'm writing a game in Visual Studio 2010, using the XNA 4.0 framework. I
I've begun writing a game using XNA Framework and have hit some simple problem
Here's the situation, I am writing the framework for a code war contest. As
I'm writing a game with LibGDX, and I'm trying to save an XML file,
I'm writing an AS3/Flex4 game engine, and I want to have a base class

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.