On Aug 27, 7:33 pm, Lawrence D'Oliveiro <[EMAIL PROTECTED] central.gen.new_zealand> wrote: > In message <[EMAIL PROTECTED]>, Torsten Bronger wrote: > > > So I'd like to know a means to tell *explicitly* what I want to > > import. Maybe I could use the imp module but that's ugly. > > That seems to be the standard Python-provided way to explicitly import the > file you want from the place you want. > > > I mean, there are hundreds of modules on my harddisk, so trying to avoid > > nameclashs should not be the solution... > > That is what namespace qualifiers are for, e.g. > > import my_custom_stuff.parser > > versus > > import parser > > > John Machin writes: > > >> 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. > >> """ > > > ... the whole systems seems largely arbitrary, which I don't > > believe. ;-) > > The documentation <http://docs.python.org/lib/module-sys.html> says quite > clearly that the search order is controlled by sys.path. So why not > manipulate that to get the effect you want?
Short answer: it doesn't work. The documentation that I quoted previously says that if a module is is built in, it will be selected, *before* sys.path is examined. The OP's original message stated quite clearly that the directory containing his own parser.py is at the front of sys.path. > > > "parser" is built-in on Windows but not on Linux. > > It is standard on all platforms > <http://docs.python.org/lib/module-parser.html>. "standard" != "builtin" -- http://mail.python.org/mailman/listinfo/python-list