Strange import bug

Colin Brown cbrown at metservice.com
Mon Nov 24 18:41:52 EST 2003


"Adeodato Simó" <asp16 at alu.ua.es> wrote in message
news:mailman.1043.1069714565.702.python-list at python.org...
...
The first (default) entry in sys.path is '', which means (I think) the
current directory. So sys.path.append('./abc') appends after this entry;
then, on "import abc", python uses first '' entry, which means it looks
under current directory where it finds "abc" which gets imported *as a
module*.
...

Okay, but why does python not complain when it tries to import the
current directory as a module? I would expect an error, maybe:
"ImportError: xxx is not a valid python module"

If it is considered a valid python module and is executing it then who
knows what it is doing.

There is still also the question of why the prepended path option fails
in some cases under Win2K for me.

Thanks
Colin Brown
PyNZ







More information about the Python-list mailing list