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?

2
  • 2
    That's not what __all__ is for. Commented Jun 30, 2013 at 16:20
  • __all__ limits what is being imported from a module. It does not expand it. Commented Jun 30, 2013 at 16:21

1 Answer 1

-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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.