zjm1126
zjm1126

Reputation: 66777

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

a.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

Upvotes: 0

Views: 704

Answers (3)

alicederyn
alicederyn

Reputation: 13257

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

Upvotes: 3

Alex Martelli
Alex Martelli

Reputation: 882381

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

Upvotes: 0

avpx
avpx

Reputation: 1922

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

Upvotes: 0

Related Questions