Path problem

Lars Yencken lljy at internode.on.net
Sun Dec 12 23:48:29 EST 2004


Hello,

I'm working on a project where my python modules are using persistent 
files in the same directory. As an example, we're using rpy, so a piece 
of python code might read:

	from rpy import *

	rScript = 'myScript.r'

	r.source(rScript)

Now the problem with this is that when I run this from the directory 
above, or any other directory than the directory containing the R 
script, this doesn't work, and understandably too.

Is there some easy way to get around this? I can't (and don't want to) 
hard code paths, since they'll be different on every workspace I check 
out from the repository.

If there's a way that I can get the directory of the module file 
itself, then that's all I need to fix this for good.

Thanks,
Lars




More information about the Python-list mailing list