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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:43:46+00:00 2026-06-11T13:43:46+00:00

This is more of a convenience than a real problem, but the project I’m

  • 0

This is more of a convenience than a real problem, but the project I’m working on has a lot of separate files, and I want to basically be able to run any of those files (that all basically only contain classes) to run the main file.

Now in the middle of writing the first sentence of this question, I tried just importing main.py into each file, and that seemed to work fine and dandy, but I cant help but feeling that:

  1. it might cause problems, and
  2. that I had problems with circular imports before and I am somewhat surprised that nothing came up.
  • 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-11T13:43:48+00:00Added an answer on June 11, 2026 at 1:43 pm

    First let me say: this is most likely a bad idea, and it’s definitely not at all standard. It will likely lead to confusion and frustration down the road.

    However, if you really want to do it, you can put:

    if __name__ == "__main__":
        from mypackage import main
        main.run()
    

    Which, assuming mypackage.main.run() is your main entry point, will let you run any file you want as if it were the main file.

    You may still hit issues issues with circular imports, and those will be completely unavoidable, unless mypackage.main doesn’t import anything… Which would make it fairly useless 🙂

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

Sidebar

Related Questions

I know this is an NP-hard problem, but a lot of our users have
I want to know this more in detail. Is it a realtime scheduler? An
This is more for information then a problem. (On searching Stack Overflow I found
edit4: wikified, since this seems to have morphed more into a discussion than a
There was some code like this: // Convenience to make things more legible in
To make this more clear, I'm going to put code samples: $file = fopen('filename.ext',
UPDATE: I've been playing around with this more, and it seems like tmux's clear-history
I am wondering if there is a way to handle this more elegantly. After
Ok, I'm going to try to make this more clear because my last question
I have a label on my asp.net page, it looks like this: more info

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.