A less than fully robust way is to use os.path.commonprefix:
import os
Fullpath = 'c:\\users\\test\\appdata\\local\\temp\\tempDir\\common\\test.txt'
TempPath = 'c:\\users\\test\\appdata\\local\\temp\\tempDir\\'
print os.path.commonprefix([Fullpath, TempPath])
# c:\users\test\appdata\local\temp\tempDir\
Be aware thought that the function does not know anything about paths; it is just a character by character deal.
Then use str.partition to get the part you are interested in:
>>> print Fullpath.partition(os.path.commonprefix([Fullpath, TempPath]))
('', 'c:\\users\\test\\appdata\\local\\temp\\tempDir\\', 'common\\test.txt')
If you have a situation like so:
Fullpath = 'c:\\users\\test\\appdata\\local\\temp\\tempDir\\common\\test.txt'
TempPath = 'c:\\users\\test\\appdata\\local\\temp\\tempDir\\co'
It is better to wrap the common prefix with os.path.dirname
>>> os.path.dirname(os.path.commonprefix([Fullpath, TempPath]))
c:\users\test\appdata\local\temp\tempDir\
But that still does not fix a situation like this:
Fullpath = 'c:\\users\\test\\..\\test\\appdata\\local\\temp\\tempDir\\common\\test.txt'
Where you need to resolve full absolute path names before parsing.