0

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

zjm1126
  • 58,281
  • 75
  • 169
  • 215

3 Answers3

3

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

Alice Purcell
  • 12,034
  • 6
  • 45
  • 55
0

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

avpx
  • 1,872
  • 15
  • 13
0

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

Alex Martelli
  • 811,175
  • 162
  • 1,198
  • 1,373
  • 1
    In defense of "import *": `from math import *` is arguably reasonable, when one manipulates lots of mathematical formulas. – Eric O Lebigot Jan 02 '10 at 10:42