[Tutor] Why can't I import this?

Kent Johnson kent37 at tds.net
Wed Nov 29 04:48:50 CET 2006

Dick Moores wrote:
> At 07:20 PM 11/28/2006, Kent Johnson wrote:
>> Try
>>from mine.toolTipDemo import demo
>> mine.toolTipDemo points to the module, then you need to reference a name
>> defined in the module. (You must have something called intSpell in
>> intSpell.py.)
> Interestingly (or not) it just hit me that I should try that, and it 
> worked. So I suppose that if I want to use tooltips in a Tkinter 
> program, I can just use  "from mine.toolTipDemo import *" and use 
> what I need. (Haven't tried that yet, however.)

Yes, you can do that but in general that style is not recommended. It 
makes it hard to figure out where names are defined and you can import 
more than you really want. Better is to just import what you want, e.g.
from mine.toolTipDemo import A, b, CC

or import the module with an alias:
import mine.toolTipDemo as TTD

then refer to e.g.


More information about the Tutor mailing list