my isn't imported

John Machin sjmachin at
Mon Aug 27 00:14:22 CEST 2007

On Aug 27, 1:36 am, Torsten Bronger <bron... at>
> Hallöchen!
> I have a module in the same directory as the main module.
> In the main module, I import "parser".  On Linux, this works as
> expected, however on Windows, it imports the stdlib parser module.
> sys.path[0] points to the directory of my in both cases.
> What went wrong here?

Ask a literal question, get a literal answer :-)

1. Failure to consider that problems can happen [and therefore will
happen [1]] when there are multiple entities with the same name.

2. Failure to RTFabulousM:
Details of the module searching and loading process are implementation
and platform specific. It generally involves searching for a ``built-
in'' module with the given name and then searching a list of locations
given as sys.path.

3. Failure to attempt enlightenment by using the -v option:
import parser # builtin
(on Windows)

Suggestion: Avoid the confusion. Rename your module. If it is actually
intended as a replacement for the builtin one, then you can do:
   import replacementparser as parser

[1] Codex Murphius, circa 5000 BCE


More information about the Python-list mailing list