Attribute not added to module after importing

前端 未结 1 748
失恋的感觉
失恋的感觉 2021-01-22 02:55

I\'ve made the following lab:

vagrant@ubuntu-xenial:~/test$ tree
.
├── pack1
│   ├── __init__.py
│   ├── mod1.py
│   └── pack2
│       ├── __init__.py
│       ├─         


        
相关标签:
1条回答
  • 2021-01-22 03:32

    A module is added as an attribute of its package when its import finishes. (Note that this can interfere with circular relative imports.) Here, pack2 immediately imports mod2, so (regardless of further completed imports like that of mod3) it doesn’t appear in the pack1 dictionary during mod2’s execution.

    0 讨论(0)
提交回复
热议问题