语法
all(iterable)
只采用一个参数
与any函数一样,iterable-包含元素的任何可迭代
实例内容:Python代码文件test.py如下
def _local_func(): print 'local' def test(): _local_func()
通过all函数来控制import *的导出范围:
__all__ = ['test'] def _local_func(): print 'local' def test(): _local_func() def test1(): _local_func()
执行结果如下:
>>> from test import * >>> test1() Traceback (most recent call last): File "", line 1, in NameError: name 'test1' is not defined >>> test() local >>>