On Mon, 18 Oct 2010 14:24:39 -0700 (PDT) Devin M <devin...@gmail.com> wrote:
> Hello, I am using os.path to get the absolute paths of a few > directories that some python files are in. > FIlePath = os.path.dirname(os.path.realpath(__file__)) > which returns a path similar to /home/devinm/project/files > Now I want to get the directory above this one. (/home/devinm/ > project/) Is there a simple way to do this? I was considering spliting > apart the path and then reconstructing it with the last folder left > off. Hope theres a better way to do this. > Maybe os.relpath("..", FilePath) ? Python > 2.6 only. Don't know if that does what you want, but from the description, it seems to fit: <http://docs.python.org/library/os.path.html> os.path.relpath(path[, start]) Return a relative filepath to path either from the current directory or from an optional start point. start defaults to os.curdir. /W -- To reach me via email, replace INVALID with the country code of my home country. But if you spam me, I'll be one sour Kraut. -- http://mail.python.org/mailman/listinfo/python-list