Python: import from levels 1+ down

Say I am importing an unnecessary long full path:

from pandas.core.series import Series

      

More general imports are simple:

from pandas import Series

      

with which I can view the full path with:

Series
Out[6]: pandas.core.series.Series

      

Here is the source of my confusion. There is __init__

no import from core import *

(or core.series

for that matter) anywhere in the top level . The module __init__

for is .core

also empty.

What allows me to use a simple from pandas import Series

rather than a full path or, more generally, import a module, function, variable, or class that is "several levels down"?

+3


source to share


1 answer


You have a file inside__init__.py

:

from pandas.core.api import *

      



in which it is Series

imported
.

+2


source







All Articles