Newbie IDLE - import issues

sismex01 at hebmex.com sismex01 at hebmex.com
Tue Nov 26 10:10:03 EST 2002


> From: Kenny Tilton [mailto:ktilton at nyc.rr.com]
> Sent: Tuesday, November 26, 2002 9:10 AM
> 
> 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>


heh, feer not, imports work in IDLE just fine :-)


> 
> > 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
> 


Ahh! I *almost* know what's going on...


> 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.)


does the "cells" directory have a "__init__.py" file, even if
it's an empty file?  Since your using "cells" as a "package"
(a "module of modules", if you will), it needs a "__init__.py"
file to indicate the fact to the importer.


> 
> > 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
> 


I think it's your package import thingy, does it match?

-gustavo




More information about the Python-list mailing list