Newbie IDLE - import issues

Kenny Tilton ktilton at nyc.rr.com
Tue Nov 26 10:09:34 EST 2002


sismex01 at hebmex.com wrote:
>>From: Kenny Tilton [mailto:ktilton at nyc.rr.com]
>>Sent: Tuesday, November 26, 2002 8:34 AM
>>
>>I must misunderstand things badly.
>>
>>Using IDLE: I have import statements where apparently 
>>necessary. I hit Ctrl-F5 and I see print statements at
>>the end of imported modules fire.
>>
>>But I still get errors on imported stuff being undefined.
>>
>>Then I open the imported file and ^f5 it and then I can ^f5 
>>successfully the importing file which before gave me an error.
>>
>>any help with this would be appreciated. As is I end up 
>>having to open ten files and run them manually every morning.
>>
> 
> 
> Without more information ("detailed" information :-)

understood. i'll put together a reproducible if necesaary, but it will 
mean a lot of winnowing. just thought i'd check first if someone would 
say, "oh, right, import doesn't work in IDLE" <g>

> I can only say that this sounds like some module you're
> trying to import isn't in your sys.path.

no, but I supply the path:

   import cells.cell

and cells /is/ in the path. (inside the python directory, in fact.) Like 
I said, I /see/ print statements at the end of each imported module 
firing, so it's not as if Python aint finding the files. (and it gives 
an error anyway if it does not.)

 >  BUT, since
> you load it in IDLE and <F5> it, and *then* load (into
> IDLE I suppose) the "importer" module, and now it runs
> correctly, everything works as it should.

You gave me an idea. Suppose my import statements are messed up somehow, 
so by themselves they pull things into the wrong namespace. But then I 
open the imported file and f5 it. Now it gets pulled into some more 
accessible namespace. When I re-f5 the file with the bad imports, it 
does not matter because the more accessible namespace has the right stuff.

And since I /see/ the necessary imported print statements fire, ie, the 
ones which have the missing declarations, that suggests that my mess-up 
might indeed be which namespace my import statements point to. I mention 
this because I happened to look at some IDLE source and I saw all the 
from/import statements as part of a class definition, and I have been 
putting my import statements (trying both from and import) at the 
toplevel of my source, outside any other definition.

> And, with more information we might help s'more ;-)

understood my OP was deficient, as is this one. i'll cobble together a 
reproducible next if nothing above is a red flag.

thx, kenny






More information about the Python-list mailing list