0

My requirement might be a bit strange, but here it is:

I have a package called handlers. Outside of this package, I have main.py. In main.py, I need to get all the submodules under handlers. Now I can define __all__ in __init__.py but that would have to be updated everytime I add a new submodule in the directory. So is there a way to automatically keep __all__ updated?

prongs
  • 9,422
  • 21
  • 67
  • 105

1 Answers1

-1

You need to explicitly state where you're getting the modules from in main.py.

Even if it becomes 50+ lines after constant updating, so be it. Don't use the from handlers import * notation.

yurisich
  • 6,991
  • 7
  • 42
  • 63