importing: what does "from" do?

Charles T. Smith cts.private.yahoo at gmail.com
Thu Jan 21 09:20:05 EST 2016


What does "from (module) import (func)" do?

Please don't tell me that I shouldn't ask because real programmers
know not to have circular dependencies ...

I have no idea what was imported before.  I just want to import hexdump().
Unfortunately, this does not work:

  from utilities import hexdump

    ImportError: cannot import name hexdump

Now, I shouldn't have a problem because the programmers before me didn't
understand either, and so just duplicated it everywhere, but I'd really
like to do it right.

I would have thought that "from" would allow me to import just one
symbol.  Now, for all the people just chomping at the bit to tell
me about circular dependencies, would you explain to me why I get this:

  (PDB)hexdump(msg)
*** NameError: name 'hexdump' is not defined


P.S. can I get a list of all the loaded symbols and/or modules?



More information about the Python-list mailing list