gagsl-py2 at yahoo.com.ar
Fri Jun 22 03:22:00 CEST 2007
En Thu, 21 Jun 2007 17:03:42 -0300, David Abrahams
<dave at boost-consulting.com> escribió:
> Another example: I was recently working on some code that did an
> import from inside a class method. That import was failing. I moved
> the import to the top of the file (at module scope) and it succeeded.
> I'm fairly sure that nobody was monkeying around with sys.path in that
> case. Can anyone think of a likely explanation?
The imported module and the main script both reside on the same directory,
and it is executed from there. sys.path contains '' in this case (not the
full path). The script changes the current directory (os.chdir) after
doing other imports and initialization. From now on, importing a module
from the original directory doesn't work anymore.
More information about the Python-list