So I have this python code:
print os.path.commonprefix([r'C:\root\dir',r'C:\root\dir1'])
Real Result
C:\root\dir
Desired result
C:\root
Question 1
Based on os.path.commonprefix
documentation:
Return the longest path prefix (taken character-by-character)
Is there a similar function that:
Return the longest path prefix (taken dir by dir)
Question 2
if commonprefix
is implemented in os.path
why isn't it path oriented, meaning return my desired result and not the real one?
Note:
I can implement this easily by myself but if it is already implemented why not using it?