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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:46:27+00:00 2026-06-01T14:46:27+00:00

I was reading the sourcode for a python project and came across the following

  • 0

I was reading the sourcode for a python project and came across the following line:

from couchexport.export import Format

(source: https://github.com/wbnigeria/couchexport/blob/master/couchexport/views.py#L1 )

I went over to couchexport/export.py to see what Format was (Class? Dict? something else?). Unfortunately Format isn’t in that file. export.py does however import a Format from couchexport.models where there is a Format class (source: https://github.com/wbnigeria/couchexport/blob/master/couchexport/models.py#L11).

When I open up the original file in my IDE and have it look up the declaration, in line I mentioned at the start of this question, it leads directly to models.py.

What’s going on? How can an import from one file (export.py) actually be an import from another file (models.py) without being explicitly stated?

  • 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-01T14:46:28+00:00Added an answer on June 1, 2026 at 2:46 pm

    If module a does a from b import Foo, then Foo is a member of a afterwards and accessible as a.Foo. It’s only consequent that you can now import it too using from a import Foo.

    This is commonly used if you have a large library distributed across multiple files and you want them to be accessible from a single location. Let’s say you have a package foo with the following layout:

    foo/
        a.py
        b.py
        c.py
        __init__.py
    

    a.py, b.py, c.py, define the classes A, B and C, respectively.

    If you wanted to use those classes, you’d normally have to write

    from foo.a import A
    from foo.b import B
    from foo.c import C
    

    This has at least two problems:

    1. Much code (three lines) is needed for this simple import
    2. The library author can now no longer change the file/class association afterwards, because that would break existing code.

    So normally you just put the following in the __init__.py:

    from a import A
    from b import B
    from c import C
    

    Now you put all the pieces together in a single place and all of the classes are accessible with one import:

    from foo import A,B,C
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Reading through wikipedia I came across the concept of Sprints in Agile development. From
Reading on another forum I've came across the world of CSS Frameworks. The one
Reading source code of my current project, I see: [self retain] in one class,
reading this https://developers.google.com/in-app-payments/docs/tutorial Quoted from the above page: Because you sign the JWT using
Reading a blog entry by Eric Lippert , I came across this snippet: ...you're
Reading source code of sample projects, such as Beast and Bort, are recommended as
Reading code from other posts, I'm seeing something like this. struct Foo { Foo()
Reading this site, I've found this : [The] line private static final Foo INSTANCE
Reading the following article, I managed to put a legend outside plot. How to
Reading the Python 3.2 tutorial here , towards the end one of the examples

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.