importing: what does "from" do?
Steven D'Aprano
steve at pearwood.info
Thu Jan 21 11:28:00 EST 2016
On Fri, 22 Jan 2016 02:53 am, Charles T. Smith wrote:
> What I need is tools to find the problems. In particular, why doesn't
> python give me more of a clue where the problem is? It would be cool
> if it would tell me exactly what module to look at, which symbol(s)
> were colliding.
The problem isn't that symbols are colliding, it is that you are looking for
symbols that *don't exist* in the place you tell Python to look.
If you run
from math import hexdump
you will get an ImportError, not because of a collision, but because there
is no math.hexdump.
If you run
from utilities import hexdump
and Python gives you an ImportError, the most likely issue is that there is
no such name "hexdump" in that file.
Are you sure you are looking at the same file? What does this tell you?
import utilities
print(utilities.__file__)
Does it match what you expect?
--
Steven
More information about the Python-list
mailing list