Python: Why "__all__" doesn't work for import?
Question: File structure;

    
    
    ./__init__.py
      a.py
        /lib
        __init__.py
        Foo1.py # contains `class Foo1`
        Foo2.py # contains `class Foo2`
        # so on ...
    

Tested this in `a.py` and worked, doing this;

    
    
    from lib.Foo1 import Foo1
    from lib.Foo2 import Foo2
    

But, when I do `from lib import *` doing `__all__ = ["Foo1", "Foo2"]` in
`__init__.py` it doesn't work.

Error: `<type 'exceptions.TypeError'>: 'module' object is not callable`

What I'm missing?

Here is `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() 
    

// used this refs:  
// <http://docs.python.org/2/tutorial/modules.html#importing-from-a-package>  
// [Loading all modules in a folder in
Python](http://stackoverflow.com/q/1057431/362780)


Answer: 
    from lib import *
    

Will import everything in `lib` to the current module, so our `globals()`
looks like:

    
    
    {'Foo1':<module lib.Foo1>,
     'Foo2':<module lib.Foo2>}
    

Whereas

    
    
    from lib.Foo1 import *
    from lib.Foo2 import *
    

Makes our `globals()` become

    
    
    {'Foo1':<class lib.Foo1.Foo1>,
     'Foo2':<class lib.Foo2.Foo2>}
    

So in the first case we're just importing modules, not the classes inside them
which is what we want.

