Strange import bug

Colin Brown cbrown at metservice.com
Mon Nov 24 17:30:24 EST 2003


I have instances where Python 2.3.2 import both does not work or error. It
can be demonstrated under Win2k and Linux by doing the following:

1. Create a subdirectory "abc"
2. In directory "abc" create a blank "__init__.py"
3. In directory "abc" create a file "abc.py" containing "print 'this is
abc'"
4. Interactively run python interpreter
>>> import sys
>>> sys.path.append('./abc')
>>> import abc
>>>

It sometimes works for me (in similar situations) if you do:
5. Interactively run python interpreter
>>> import sys
>>> sys.path.insert(0,'./abc')
>>> import abc
this is abc
>>>

Can anyone explain this behaviour please?

Colin Brown
PyNZ







More information about the Python-list mailing list