How to import classes defined in __init__.py

前端 未结 7 518
你的背包
你的背包 2020-11-29 17:23

I am trying to organize some modules for my own use. I have something like this:

lib/
  __init__.py
  settings.py
  foo/
    __init__.py
    someobject.py
           


        
相关标签:
7条回答
  • 2020-11-29 17:58

    Yes, it is possible. You might also want to define __all__ in __init__.py files. It's a list of modules that will be imported when you do

    from lib import *
    
    0 讨论(0)
提交回复
热议问题