0

I have a module mymodule with several submodules, let’s say

mymodule/
   __init__.py
   module1.py
   module2.py
   ...

For side-effects reasons, I need all those submodules to be run when mymodule is imported.

I tried adding the following to __init__.py

from . import *

But that didn’t work (the submodules were not imported when mymodule was)

I solved it by using pkgutil as described in the answers to this question

My question is the following :

Why doesn’t from . import * work as one would expect?

(when from . import module1 for examples works as expected)

Nephanth
  • 480
  • 3
  • 12

0 Answers0