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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:34:27+00:00 2026-06-18T04:34:27+00:00

When a module mod1.py and mod2.py exists in the same directory, I can import

  • 0

When a module mod1.py and mod2.py exists in the same directory, I can import mod2 in mod1 directly as

import mod2

or relative with

from . import mod2

Is there any preferable way to do this?

I am asking because if mod1 is imported in mod2 as well, the relative import will not work.

  • 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-18T04:34:29+00:00Added an answer on June 18, 2026 at 4:34 am

    Implicit relative imports are gone in Python 3. So clearly, they are deprecated, primarily because they collide with absolute imports (i.e. if there was a global module mod2, how would you import that?).

    You are right that circular explicit relative imports don’t work; this is a bug. As a consequence, the preferable way is to avoid circular imports.

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

Sidebar

Related Questions

I have a directory tmp that has 3 test node.js modules [mod0.js, mod1.js, mod2.js]
Three module exists. Cfg, Main and Component Cfg.py value = 0 Component.py import Cfg
module Hints module Designer def self.message Hello, World! end end end is there any
using module sys one can get command line arguments like this import sys for
mod1.py import mod2 class Universe: def __init__(self): pass def answer(self): return 42 u =
The module 'SimpleAds' is kinda new and I can't find any documentation about it.
I have a module like the following defined in one file define(['mod1', 'mod2'], function
A module can be unloaded, so how can I tell for sure if it
We have several independent modules (e.g. mod1, mod2, mod3 ...) under a project 'proj1'.
my xml is below: <Demo> <ClientCompanyId CompanyId=1> <MyMenu> <module MenuType=0 ModID=Mod1 ModuleID=1 Perm=False Text=Basic

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.