How to find out the directory that the py file is in?

PengYu.UT at gmail.com PengYu.UT at gmail.com
Tue Oct 24 19:39:29 EDT 2006


I have the following python script and some_command in the same
directory. I have to call the python script from that directory.
Otherwise, some_command won't be found. I'm wondering how to make the
following script working no matter what the working directory is.

Thanks,
Peng

#!/usr/bin/env python

import os

cmd = "./some_command";
print cmd
os.system(cmd);




More information about the Python-list mailing list