Catherine Moroney <catherine.m.moro...@jpl.nasa.gov> writes:

> In what order does python import modules on a Linux system?

An import caused by a statement is done when that statement is executed.
So the answer to that question is: in the order the statements occur in
the execution flow.

> I have a package that is both installed in
> /usr/lib64/python2.5/site-packages, and a newer version of the same
> module in a working directory.

Ah, you're asking about the search path for importing modules.

You would do well to work through the entire Python tutorial
<URL:http://docs.python.org/tutorial/> to cover the basics like that.
Don't merely read it; actually *do* it, exploring each example and
experimenting to understand before proceeding.

The module import search path is part of that coverage
<URL:http://docs.python.org/tutorial/modules.html#the-module-search-path>.

> I want to import the version from the working directory, but when I
> print module.__file__ in the interpreter after importing the module,
> I get the version that's in site-packages.

You will be interested in the features enabled by PEP 328
<URL:http://www.python.org/dev/peps/pep-0328/>, specifically the feature
of relative imports.

-- 
 \     “When I turned two I was really anxious, because I'd doubled my |
  `\   age in a year. I thought, if this keeps up, by the time I'm six |
_o__)                                  I'll be ninety.” —Steven Wright |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to