2

Is there a way to automatically import modules from an implicit namespace package (PEP420), if we are not allowed to have __init__.py files?

I decided to split my package mylib into two namespace packages: mylib-core and mylib-extra.

Before, when I would run import mylib, I would automatically import mylib.module, mylib.module2, etc., using code in my __init__.py file:

# __init__.py

__all__ = [
    'module1',
    'module2',
]

from . import *

Is there a way to accomplish the same behaviour in a namespace package? I have a lot of existing code that expects this behaviour.

ostrokach
  • 17,993
  • 11
  • 78
  • 90

0 Answers0