Python Importing object that originates in one module from a different module into a third module
Posted
by
adewinter
on Stack Overflow
See other posts from Stack Overflow
or by adewinter
Published on 2012-04-07T10:59:55Z
Indexed on
2012/04/07
11:29 UTC
Read the original article
Hit count: 242
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?
© Stack Overflow or respective owner