Help with paths

Chris Rebert clp2 at rebertia.com
Mon Oct 18 23:38:47 CEST 2010


On Mon, Oct 18, 2010 at 2:24 PM, Devin M <devinmrn at 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?

parent_dir = os.path.split(FilePath)[0]

Note that os.split() does not work like str.split().
Also, don't use CamelCase for non-classes.

Cheers,
Chris
--
http://blog.rebertia.com



More information about the Python-list mailing list