Is there a way to add a directory to the locations that python look at when you call __import__ ?

I need to import some scripts from a user folder at runtime, and since __import__ doesn't accept absolute file names, I'd like to try this. Copying the script to the program directory isn't a solution I'm willing to risk (requires administrator privileges on some machines).

You simply append the directory to PYTHONPATH before you import your custom module:

import sys
# appends to PYTHONPATH  the location of the example codes

Never thought it would be that easy. Thanks.