Python __all__系统变量

#__all__系统变量的使用
'''
__all__可以赋值一个字符串列表,列表中的元素表示外界调用该py文件可以使用的函数或者类
如果使用了__all__系统变量,并且调用该py文件使用的是from xxx import *这种方式
那么将无法调用没有写在__all__变量中的方法


注意:通过 "import send"方式或者"from send import xxx"方式,那么仍然可以调用相应的方法


'''
__all__ = ["Msg"]

class Msg(object):
        def send(self):
                print("send message .")



def test():
        print("i am test from send.py")


if "__main__" == __name__:
        test()
else:
        print("send.py 正在被调用.")
原文地址:https://www.cnblogs.com/zhanggaofeng/p/9696035.html