importing modules question

Peter Hansen peter at engcorp.com
Thu Apr 18 23:43:34 EDT 2002


Adonis Vargas wrote:
> 
> how can i load modules from a different path ?
> 
> i.e.
> 
> a_python_script.py is in /tmp
> but X user created Y.py script in a folder called /tmp/scripts
> then i want load the script in /tmp/scripts

Use the PYTHONPATH environment variable, or if you are
okay with hardcoding something into the script itself,
you can do

  import sys
  sys.path.append('/tmp/scripts')

before the other imports.

-Peter



More information about the Python-list mailing list