my parser.py isn't imported

Lawrence D'Oliveiro ldo at geek-central.gen.new_zealand
Mon Aug 27 05:33:45 EDT 2007


In message <87ps19q5fs.fsf at wilson.homeunix.com>, 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?

> "parser" is built-in on Windows but not on Linux.

It is standard on all platforms
<http://docs.python.org/lib/module-parser.html>.




More information about the Python-list mailing list