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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:53:15+00:00 2026-05-23T18:53:15+00:00

If have this module # mymodule.py import __main__ And I import it in the

  • 0

If have this module

# mymodule.py
import __main__

And I import it in the python interpreter:

>>> import mymodule
>>> dir(mymodule)
['__builtins__', '__doc__', '__file__', '__main__', '__name__', '__package__']
>>> dir()
['__builtins__', '__doc__', '__name__', '__package__', 'mymodule']
>>> import sys
>>> sys.modules['__main__'] == mymodule.__main__
True
>>> mymodule == mymodule.__main__.mymodule
True

I’ve just created a circular reference by importing a module that imports __main__. Is this bad?

  • 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-23T18:53:16+00:00Added an answer on May 23, 2026 at 6:53 pm

    No. Python has no problem with circular references like this. The only thing you must be sure of is that you don’t use a name from the other module until it has been defined.

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

Sidebar

Related Questions

I have a problem with python module import. I installed django (this can be
In a Python system for which I develop, we usually have this module structure.
I'm having a module import issue. using python 2.6 on ubuntu 10.10 I have
I have this external module of my system and I thought to integrate it
Currently, in my settings module I have this: LOGIN_URL = '/login' If I ever
i have created a module with this among others this function in it: <?php
I have a method in a url rewriting module that looks like this public
Let us say if I have a Perl module Resounces.pm with this code snippet
Drupal 6.x I have this module that manages four different content types. For that
I have a module MyModule . I dynamically load classes into it. How can

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.