In python explicit import are the standard. You choose either to import modules or individual named stuff from those objects.
import foo from jigg import bar
Wildcard imports where you import everything from a module, is considered bad. Quoting from PEP8.
Wildcard imports (from
import *) should be avoided, as they make it unclear which names are present in the namespace, confusing both readers and many automated tools.
To me, this has always seemed a matter of readability and tool usability. Keeping you code clean so you can see what is going on, but not a major issue. Last friday changed my mind.
I was doing some minor cleanup in our modules, removing unneccesary code and imports as identified by the
pylint tool (love it). Then I ran the test suite and everything crashed. Which was weird, since I hadn't done any refactoring at all. I had just removed "unneccesary" code. Some investigation later and I found the bug. Our code structure was roughly the following.
# Module alpha import json # This module isn't used anywhere in the module [..] bunch of code
# Module beta [..] bunch of code from alpha import *
# Module charlie from beta import * [..] bunch of code json.loads(...) [..] more more code
So removing the "unneccesary" import of json in alpha caused a method in charlie to fail, even though it didn't import directly from alpha or was dependent on any functions in alpha.
It was pretty lucky for me that those were the only two wildcard imports we had, otherwise it would have been very tricky finding out where the import originated from.
Lesson learned. Wildcard imports are bad. Both for readability and for their impact on refactoring.