python - from __future__ import absolute_import not working? sub-modules not visible -


so i've got module bbb in main scope ccc.

i'm adding library called tools has 2 modules called bbb , ccc:

tools

  • __init__.py
  • aaa.py
  • bbb.py
  • ccc.py

in bbb.py i'm importing main scope bbb with:

from __future__ import absolute_import import bbb 

and in ccc.py doing same thing:

from __future__ import absolute_import import ccc 

but when import tools , dir can see:

['__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__', 'aaa'] 

but bbb , ccc don't seem visible.

am missing here?

but when import tools , dir can see:

['__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__', 'aaa'] 

but bbb , ccc don't seem visible.

importing package doesn't automatically load submodules. if want use tools.bbb package, need do

import tools.bbb # or tools import bbb 

import tools won't cut it. alternatively, can have tools explicitly load submodules in __init__.py:

# in __init__.py . import aaa, bbb, ccc 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -