RosettaCodeData/Task/Find-common-directory-path/Python/find-common-directory-path-...

4 lines
181 B
Python

>>> paths = ['/home/user1/tmp/coverage/test', '/home/user1/tmp/covert/operator', '/home/user1/tmp/coven/members']
>>> os.path.dirname(os.path.commonprefix(paths))
'/home/user1/tmp'