How to - import code not in current directory

Dmytro Lesnyak Dmytro.Lesnyak at
Thu Nov 17 14:43:44 CET 2005

Yes, you can. 
Try this:

import sys

import bar

Good luck!

-----Original Message-----
From: at
[ at] On Behalf Of py
Sent: 17. marraskuuta 2005 15:19
To: python-list at
Subject: How to - import code not in current directory

I have a python script that I want to test/debug.  It contains a class
which extends from some other class which is located in some other
python file in a different directory.

For example:

[script to test]

[needed python files]
c:\some\other\directory\ I want to test/debug, which needs imports ...but in order to test out foo (in the python shell) I normally
copy into the same directory as this is painful.
Is there some way that I can have python know about the directory where is located, like a system variable, etc?  If so, how do I set
that up?



More information about the Python-list mailing list