When I run the following script:
c:\Program Files\foo\bar\scripy.py
How can I refer to directory 'foo'?
Is there a convenient way of using relative paths?
I’ve done it before with the string module, but there must be a better way (I couldn’t find it in os.path).
Will return the second half of a SPLIT that is performed on the path parameter. (head – the directory and tail, the file) Put simply it returns the directory the path is in. You’ll need to do it twice but this is probably the best way.
Python Docs on
pathfunctions:http://docs.python.org/library/os.path#os.path.expanduser