有人可以用Python解释__all__吗? [英] Can someone explain __all__ in Python?
本文介绍了有人可以用Python解释__all__吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我越来越多地使用Python,并且不断看到在不同的__init__.py
文件中设置的变量__all__
.有人可以解释这是什么吗?
I have been using Python more and more, and I keep seeing the variable __all__
set in different __init__.py
files. Can someone explain what this does?
推荐答案
这是该模块的公共对象的列表,由import *
解释.它会覆盖默认的内容,即隐藏以下划线开头的所有内容.
It's a list of public objects of that module, as interpreted by import *
. It overrides the default of hiding everything that begins with an underscore.
这篇关于有人可以用Python解释__all__吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文