On 10/18/2010 2:24 PM Devin M said...
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.

Yes -- in the same module...

>>> os.__file__
'C:\\Python26\\lib\\os.pyc'
>>> os.path.dirname(os.__file__)
'C:\\Python26\\lib'


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to