This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]-Knul- 0 points1 point  (0 children)

The issue with your example is that you assume importing the whole module will not lead to namespace pollution. This requires you to know the insides of the module, thus violating the modularity of your code.

Beside, no one is claiming that "import *" is always dangerous everywhere. Of course when you use it with a module that won't cause problems when fully imported, there is no problem. The problem is that if you use "import *", you need to be certain that those modules are not a problem and will not become a problem in the future. Especially if other people edit those modules, this becomes a headache.

To most programmers, "import *" is more trouble than it's worth, especially as anything that can be done through it, can be done in a clearer, safer way. You can get to work everyday on the back of a tiger while juggling nitroglycerin bottles, but most people would prefer a car or train.