Re: importing: what does "from" do?

2016-01-21 Thread John Gordon
In "Charles T. Smith" writes: > from utilities import hexdump > ImportError: cannot import name hexdump The most likely explanation here is that the 'utilities' module simply does not contain something named 'hexdump'. Have

Re: importing: what does "from" do?

2016-01-21 Thread Charles T. Smith
On Thu, 21 Jan 2016 15:31:45 +, John Gordon wrote: > The most likely explanation here is that the 'utilities' module simply > does not contain something named 'hexdump'. > > Have you inspected the 'utilities' module? Does it, in fact, contain > something named 'hexdump'? Yes --

Re: importing: what does "from" do?

2016-01-21 Thread John Gordon
In "Charles T. Smith" writes: > > The most likely explanation here is that the 'utilities' module simply > > does not contain something named 'hexdump'. > > > > Have you inspected the 'utilities' module? Does it, in fact, contain >

Re: importing: what does "from" do?

2016-01-21 Thread Charles T. Smith
On Thu, 21 Jan 2016 15:44:43 +, John Gordon wrote: > How did this error come up? Did the code work previously? If so, what > changed? The developers of this legacy code had this as well as other functions duplicated throughout the system, in order to avoid confronting these issues. I'm

importing: what does "from" do?

2016-01-21 Thread Charles T. Smith
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

Re: importing: what does "from" do?

2016-01-21 Thread Charles T. Smith
On Thu, 21 Jan 2016 07:52:17 -0700, Ian Kelly wrote: >> 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 > > What is utilities? Is it a module

Re: importing: what does "from" do?

2016-01-21 Thread Ian Kelly
On Jan 21, 2016 7:31 AM, "Charles T. Smith" wrote: > > What does "from (module) import (func)" do? Approximately equivalent to: import module func = module.func Except that it doesn't bind "module" to anything. > Please don't tell me that I shouldn't ask because

Re: importing: what does "from" do?

2016-01-21 Thread Steven D'Aprano
On Fri, 22 Jan 2016 02:12 am, Charles T. Smith wrote: > On Thu, 21 Jan 2016 07:52:17 -0700, Ian Kelly wrote: > >>> I have no idea what was imported before. I just want to import >>> hexdump(). Unfortunately, this does not work: >>> >>> from utilities import hexdump >>> >>> ImportError:

Re: importing: what does "from" do?

2016-01-21 Thread Steven D'Aprano
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

Re: importing: what does "from" do?

2016-01-21 Thread Charles T. Smith
On Thu, 21 Jan 2016 16:30:30 +, Charles T. Smith wrote: >> Side observation: 'int' is a bad name for a package, because it will >> shadow the name of the 'int' built-in. > > > Boy oh boy have I experienced that now! :) (it wasn't me! ;) ) --

Re: importing: what does "from" do?

2016-01-21 Thread Ian Kelly
On Thu, Jan 21, 2016 at 8:12 AM, Charles T. Smith wrote: >>> would you explain to me why I get this: >>> >>> (PDB)hexdump(msg) >>> *** NameError: name 'hexdump' is not defined >> >> Probably because the name 'hexdump' is not defined. > > > If indeed it's not

Re: importing: what does "from" do?

2016-01-21 Thread Charles T. Smith
On Thu, 21 Jan 2016 08:59:39 -0700, Ian Kelly wrote: > What happens if you just do 'import utilities'. Can you then call > utilities.hexdump? Can you see anything in the utilities module? Yes, that works! That's what I'm doing as a work around. I was trying to avoid doing that because I

Re: importing: what does "from" do?

2016-01-21 Thread John Gordon
In "Charles T. Smith" writes: > > How did this error come up? Did the code work previously? If so, what > > changed? > The developers of this legacy code had this as well as other functions > duplicated throughout the system, in

Re: importing: what does "from" do?

2016-01-21 Thread Charles T. Smith
On Thu, 21 Jan 2016 15:44:43 +, John Gordon wrote: > In that case, the problem is most likely a circular import issue, as you > mentioned. The only way to fix it is to reorganize your modules. > > How did this error come up? Did the code work previously? If so, what > changed? What I

Re: importing: what does "from" do?

2016-01-21 Thread Rustom Mody
On Thursday, January 21, 2016 at 7:53:07 PM UTC+5:30, Charles T. Smith wrote: > 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

Refactoring in a large code base (was: importing: what does "from" do?)

2016-01-21 Thread Ben Finney
Rustom Mody writes: > You may find this strategy useful: > https://pchiusano.github.io/2015-04-23/unison-update7.html > > particularly the section "Limitations of refactoring via modifying > text files in place, and what to do instead" A direct link to that section is