Python: `from x import *` not importing everything

前端 未结 3 835
独厮守ぢ
独厮守ぢ 2020-12-16 20:55

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

3条回答
  •  猫巷女王i
    2020-12-16 21:31

    shaders is a submodule, not a function.

    The syntax from module import something doesn't import submodules (Which, as another answer stated, not defined in __all__).

    To take the module, you'll have to import it specifically:

    from OpenGL.GL import shaders
    

    Or, if you only want to have a few functions of shaders:

    from OpenGL.Gl.shaders import function1, function2, function3
    

    And if you want to have all the functions of shaders, use:

    from OpenGL.Gl.shaders import *
    

    Hope this helps!

提交回复
热议问题