I have 2 directories:
subdir1 = live/events/livepkgr/events/_definst_/ subdir2 = live/streams/livepkgr/streams/_definst_/
the result should be:
diff_subdir = ../../../../streams/livepkgr/streams/_definst_/
http://docs.python.org/library/os.path.html
os.path.relpath (path [, start]) Returns the relative path to the path to the path either from the current directory or from an optional starting point.start by default os.curdir.Availability: Windows, Unix.New in version 2.6.
os.path.relpath (path [, start]) Returns the relative path to the path to the path either from the current directory or from an optional starting point.
start by default os.curdir.
Availability: Windows, Unix.
New in version 2.6.
>>> subdir1 = "live/events/livepkgr/events/_definst_/" >>> subdir2 = "live/streams/livepkgr/streams/_definst_/" >>> import os >>> os.path.relpath(subdir2, subdir1) '../../../../streams/livepkgr/streams/_definst_' >>>