Import python modules from sub-directories

Ralf Schoenian ralf at
Fri Aug 6 08:05:33 CEST 2010

Navkirat Singh wrote:
> Hi guys,
> I am new to python and would like to import certain classes in sub-directories of the working directory. I was wondering how will I be able to achieve this?
> Regards,
> Nav


put an empty file with the name in your subdirectory. I call 
it sub1 here. Assuming your filename is and your classname 
is Test you can do the following imports:

from sub1.importme import Test
import sub1.importme

You can find further explainations in the official tutorial


More information about the Python-list mailing list