Ivo van der Sangen wrote: > I was wondering if I could use relative paths in a mod_python script. At > the moment I am defining a constant string > "/path/to/dir/where/script/resides". The problem with this is that when > I move the script including files I use to get metadata I have to change > this variable. The same problem occurs when I distribute the script; the > person using it will first have to modify it, which is not what I want. Is > it possible that a mod_python script has as current working directory > the directory where the script resides? At the moment os.getcwd() > returns '/'.
import os req.write(os.path.abspath(__file__)) seems to give you the absolute path to the module you are executing. You can use the other os.path primitives to extract the directory from that and use it to locate the associated data files. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd www.holdenweb.com Love me, love my blog holdenweb.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list