开发者

is '__all__' only for 'from some import *'

开发者 https://www.devze.com 2022-12-15 10:43 出处:网络
a开发者_JS百科.py __all__=[\'b\',\'c\'] a=\'aaa\' b=\'bbb\' def c(): print \'ccc\' def d(): print \'dddd\'

a开发者_JS百科.py

__all__=['b','c']
a='aaa'
b='bbb'
def c():
    print 'ccc'
def d():
    print 'dddd'

b.py

from a import a
print a
from a import *
print a
print d#error

Are there any other uses.

thanks


Yes, it also changes what help(a) documents.


No, the purpose of __all__ is just to describe exactly what should be imported when you do from foo import *.


No other uses, except limiting the damage caused by the horrible from ... import * usage.

0

精彩评论

暂无评论...
验证码 换一张
取 消