[Tutor] how to decypther which module function was imported f rom when from module import * is used

Doug Stanfield DOUGS@oceanic.com
Sun, 27 May 2001 18:25:16 -1000


[Michael Schmitt ]
> I am trying to read code that has several line off "from 
> module import *"
> and I want to know how as I trying to read though the code 
> how I decipher
> which module a function has been imported from when the 
> fully-qualified name
> is not used.

There're kind of two answers to this.  Which one applies depends on the
code, so you pick since I haven't seen the code (hint).

Several well known and respected framework types of packages expect the use
of the 'from module import *' command.  This is well documented with those
packages.  It would be very unusual to have two of these imported in that
way in the same program.  I suppose that it is also expected you would
recognize the functions because they are usually named very descriptively
and are distinct from your program.

It is generally considered bad coding style, by the elite of the guru corp
at least, to use this form in anything else but interactive sessions.
You've run across it and been stung by one of its bad points, the namespace
confusion.  You're apparently lucky not to have another side effect, name
conflicts.

Your asking the question implies you can change the programs.  Assuming the
second point is at issue, my suggestion is to change the import statements
one at a time to see what breaks.  Change to a regular 'import module' form
and run the program.  Use each traceback to edit the file with the correct
module.function format.  It may be tedious but if this is something you
might be involved with for a while it will be worth it.

-Doug-