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 the os.path.commonprefix documentation:
Return the longest path prefix (taken for each character)
Is there a similar function that:
Return the longest path prefix ( taken dir directory )
Question 2
If commonprefix implemented in os.path , why is it os.path , that is, it returns my desired result, and not real?
Note:
I can implement this easily myself, but if it is already implemented, why not use it?
source share