exec'ing an import

Grant Griffin not.this at seebelow.org
Fri Dec 8 17:09:30 EST 2000


Hi Gang,

I had a problem the other day trying to exec an import statement, which
I used in order to collect the doc strings of a set of modules.  I kept
getting an ImportError.

I tried several different things, including using the __import__
function.  One surprising symptom was that my method worked fine when I
started the interpreter and did it interactively, but it didn't work in
a Python script.

Finally, I discovered that that when I executed the script "script.py"
using just the script name (like "script") I got the ImportError, but
when I executed it by calling the Python interpreter (ike "python
script.py") it worked fine.

Does anybody have an explanation?  This thing kindda sounds like a
security feature of some kind, but if so, can somebody give me a
reference to the docs to explain it?  (I'm using Python 2.0 and Windows
NT 4.0.)

import-ant-ly y'rs,

=g2
-- 
_____________________________________________________________________

Grant R. Griffin                                       g2 at dspguru.com
Publisher of dspGuru                           http://www.dspguru.com
Iowegian International Corporation	      http://www.iowegian.com



More information about the Python-list mailing list