Python module and __all__

后端 未结 1 353
闹比i
闹比i 2020-12-11 20:52

I trying to understand how to manage module with __all. For example, I have following structured code:

main.py
|=> /database
    |=> __ini         


        
相关标签:
1条回答
  • 2020-12-11 21:21

    Listing names in __all__ does not, by itself, import items into a module. All it does is list names to import from that module if you used from database import * syntax.

    Import session into database/__init__.py:

    from .engine import session
    
    0 讨论(0)
提交回复
热议问题