파일 구조;Python : "__all__"이 (가) 가져 오기에 적합하지 않은 이유는 무엇입니까?
./__init__.py
a.py
/lib
__init__.py
Foo1.py # contains `class Foo1`
Foo2.py # contains `class Foo2`
# so on ...
a.py
에서 이것을 테스트하고이를 수행했습니다.
from lib.Foo1 import Foo1
from lib.Foo2 import Foo2
그러나, 나는 그것이 작동하지 않습니다 __all__ = ["Foo1", "Foo2"]
__init__.py
에서하고 from lib import *
을한다.
오류 : 나는 <type 'exceptions.TypeError'>: 'module' object is not callable
를 누락 무엇입니까?
여기에 a.py
입니다.
#!/usr/bin/python
import cgi, cgitb
cgitb.enable()
from lib import *
print "Content-Type: text/html"
print ""
print "Test!"
foo1 = Foo1()
foo2 = Foo2()
// 사용이 심판 :
// http://docs.python.org/2/tutorial/modules.html#importing-from-a-package
// Loading all modules in a folder in Python