I have the following package called biographs
:
biographs (folder)
>biographs (package)
>__init__.py
>bspace.py
>bpdb.py
>bgraph.py
The __init__.py
file imports the class Pmolecule
from the module pmolecule.py
only as follows:
from .pmolecule import Pmolecule
In turn, the pmolecule.py
file imports the followin modules:
from __future__ import absolute_import
from . import bpdb
from . import bgraph
from . import bspace
Ipython has a completion feature that lets you see what are the available attributes of your object, e.g.,
In [1]: cd ~/biographs/
/Users/rdora/biographs
In [2]: import biographs
In [3]: biographs.
bgraph Pmolecule
bpdb pmolecule
bspace
As you can see after the biographs.
the list of attributes is equivalent to the complete list of modules plus the class Pmolecule
which is the only explicit import in __init__.py
.
It seems logical because all those are necessary to use the class Pmolecule
.
However, I would like to know if there is a way to import
only the class without having access to the modules it uses.
Thanks