Reputation: 3718
Suppose I read code written by someone else where "from import *" is used, how can I determine what module a function is from? Is this the reason why some people frown upon "from import *"?
Upvotes: 2
Views: 1079
Reputation: 2545
from ... import *
is the bad style not recommended by PEP8 (python style guide). There are no ways to know which module is function from except the editing the code (replacing from ... impot *
to 'import ...' and looking for errors). Unfortunately, those errors will occur only when corresponding parts of code is executed.
Upvotes: 3
Reputation: 363567
Yes, this is why from <module> import *
is considered bad style. What you can do is remove these *
imports one by one, then check which NameError
s you get and solve them one by one by explicit imports.
Upvotes: 5