Relative paths in mod_python

Jochem Berndsen wbpurzoreaqfra at qfr.ay
Sun Mar 19 13:38:50 EST 2006


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".
> [snip]

You can use Python's built-in __file__ variable. It is set to the absolute
location of your script. You can then use one of the built-in functions in
the `os' module (I forgot which) to extract the directory your script
resides.

Jochem.

-- 
E-mail address encrypted using ROT13.



More information about the Python-list mailing list