sys.path.insert - how to make it global?

Randall Hopper aa8vb at vislab.epa.gov
Sat Apr 17 11:31:21 EDT 1999


Stefan Franke:
 |Randall Hopper:
 |>     If I want to augment my Python module search path inside a Python
 |>script (so that it affects itself and imported modules), what's the best
 |>way to do this?
 |
 |sys.path *is* already global, though only accessible via the
 |sys module's namespace. Just give it a try.

I'd already tried that.  It's effect doesn't appear to be global:

   # Augment search path to pull in our C library wrappers
   sys.path.insert( 0, '/home/mylogin/Wrappers' )

   import MapFile

This allows Python to find MapFile, but this doesn't allow MapFile to
import other modules in that same Wrappers directory.

Randall






More information about the Python-list mailing list