shadowing a site module by my own module in Python
Question: I have a script `foo.py`, which tries to `from bar import baz`: basically the
hierarchy is the following:

    
    
    /
        foo.py
        bar/
            __init__.py
            baz.py
    

The problem is that the system ships its own version of `bar` in `site-
packages`, and I want to avoid importing that (I want to make sure I use the
module I ship instead of whatever version might be on the system).

Initially I thought that the order of the paths in `sys.path` will be enough
to solve the problem. However, on some systems, there's a `bar.pth` file in
`site-packages` that adds `bar` to `sys.modules`, which results in ignoring
`sys.path` completely when importing `bar` and just importing the `site-
packages` version.

How can I make sure that I import my local version of `bar`, regardless of
what might be set up on the system?


Answer: According to the
[documentation](https://docs.python.org/2/tutorial/modules.html), if you
define an environment variable, `PYTHONPATH`, which contains the folder `bar`,
that will be tried first, and thus it will import your module.

