Python: `from x import *` not importing everything

pythonpython-import

I know that import * is bad, but I sometimes use it for quick prototyping when I feel too lazy to type or remember the imports

I am trying the following code:

from OpenGL.GL import *

shaders.doSomething()

It results in an error: `NameError: global name 'shaders' is not defined'

If I change the imports:

from OpenGL.GL import *
from OpenGL.GL import shaders

shaders.doSomething()

The error disappears. Why does * not include shaders?

Best Answer

If shaders is a submodule and it’s not included in __all__, from … import * won’t import it.

And yes, it is a submodule.