I have the following project structure:
python/
..core/
..envs/
..default/
....__init__
....default.py
..dev1/
....__init__
....dev1.py
dynamic_inventory.py
in dev1 i have the following:
from ..default.default import BaseInventory
in dynamic_inventory:
import inspect
from envs.dev1 import dev1
print inspect.getmembers(dev1, inspect.isclass)
it gives me right code:
> [('BaseInventory', <class 'envs.default.default.BaseInventory'>),
> ('BatchProcessor', <class 'envs.dev1.dev1.BatchProcessor'>), ...
but dynamically:
import inspect
sys.path.append("python/envs")
m = __import__("dev1")
print inspect.getmembers(m, inspect.isclass)
gives me: []
how to do import module dynamically?
Thanks!