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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:26:23+00:00 2026-06-13T12:26:23+00:00

As the title says, do I need to reimport a module in a module

  • 0

As the title says, do I need to reimport a module in a module that I imported to my main file? Can’t find anything on this and not really sure what to search for either. Cause this don’t work until I import otherepic in epicness

file1:

import epicness
import otherepic

epicness.someother(3)

epicness:

def someother(x):
    return dosomething(x)

otherepic:

def dosomething(x):
    return x*4
  • 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-13T12:26:24+00:00Added an answer on June 13, 2026 at 12:26 pm

    Yes, you have to import everything you need in every module. If in module_a you use the function B defined in module_b then you must import module_b inside module_a, or at least import the B function from module_b.

    Explanation:

    In Python modules are objects! When you import a module its code is executed and everything that gets defined there is attached to the module object’s __dict__:

    $ echo 'a=1' > testing.py
    $ python
    Python 2.7.3 (default, Aug  1 2012, 05:14:39) 
    [GCC 4.6.3] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import testing
    >>> 'a' in testing.__dict__
    True
    

    The module’s __dict__ contains also the usual global built-ins.
    Anything that is defined inside a module uses the module’s __dict__ as global scope.
    In python there is no such a thing as a “global variable” meaning a variable accessible from every module/class/function. Globals variables are actually just a module’s instant variables.

    If you want to import some items from a module into an other module’s namespace you can use the from syntax:

    from module_a import functionA, functionB, classA, CONSTANT
    

    You can import everything using the *:

    from module_a import *
    

    But avoid using the from ... import * syntax! You’ll get namespacing clashes like in C includes. Only do this if a module states in its documentation that it is *-import safe.
    To make a module *-import safe you can define the __all__ global, which should be a sequence of strings representing the identifiers that should be exported when a *-import is executed.

    For example:

    #module_a
    A = 1
    B = 2
    __all__ = ['A']
    
    #module_b
    from module_a import *
    print(A)   #okay
    print(B)   #NameError, B was not exported!
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So, just like the title says, I need to create an application that gets
As title says, i know that new throws an exception which can be caught,
As title says need to convert a Zip file to text file , no
Like the title says I need to write a function that will sort a
As the title says , I need to find two specific words in a
I think title says what I need. I know we can use asd function
As title says, i need to get this information regarding the screen state. I
As the title says, I need an algorithm that calculates the angle made by
Just what the question title says. I'm using SpringMVC, but that's irrelevant really. I
As the title says, I need to know how many bytes the file has

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.