tags:

views:

90

answers:

3

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

A: 

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

avpx
A: 

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

Alex Martelli
In defense of "import *": `from math import *` is arguably reasonable, when one manipulates lots of mathematical formulas.
EOL
+2  A: 

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

chrispy
+1: This can be useful to know.
EOL