using modules from different paths

Robert Brewer fumanchu at amor.org
Mon Dec 8 19:16:47 EST 2003


You could try something like:

import os, sys

localDir = os.path.dirname(__file__)
sys.path.append(localDir)

...to manually add the current directory to sys.path (cut-n-paste
relative paths from there)? Not sure if that would be available then to
the import statement. Hope that sends you in the right direction.


Robert Brewer
MIS
Amor Ministries
fumanchu at amor.org

> -----Original Message-----
> From: sashan [mailto:nothing at important.com] 
> Sent: Monday, December 08, 2003 12:08 PM
> To: python-list at python.org
> Subject: using modules from different paths
> 
> 
> Hi
> 
> How do you import a module in a path that's not in sys.path. 
> I've got a 
> project and would like to split the .py files into several differrent 
> directories, say dir_a, dir_b, dir_c. Then I would like some 
> modules in 
> dir_a to be able to import modules from dir_c. How do I do this?
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 





More information about the Python-list mailing list