Python: Why should 'from import *' be prohibited?

前端 未结 6 1532
情话喂你
情话喂你 2020-12-02 14:29

If you happen to have

from  import *

in the middle of your program (or module), you would get the warning:

/t         


        
6条回答
  •  猫巷女王i
    2020-12-02 15:09

    others have given in-depth answers, I'll give a short overview answer of my understanding.. when using from you are making it so you can directly call any function in that module you imported without doing modulename.functioname (you can just call "functionname") this creates problems if you have 2 functions of the same name in different modules and also can create confusion when dealing with a lot of functions as you don't know what object/module it belongs to (from point of view of someone looking over already written code that isn't familiar with it)

提交回复
热议问题