PYTHONPATH: A scalable alternative to sys.path.insert

PYTHONPATH: A scalable alternative to sys.path.insert

Want Python to import modules in non-default dirs? You could do this:

import sys
sys.path.insert(1, '/var/mymods')

But: It doesn’t scale across many programs. And what if the dir changes?

Better: Set the PYTHONPATH environment variable — scalable and set in one place.