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

7 lines
248 B
Python
Raw Permalink Normal View History

2015-11-18 06:14:39 +00:00
>>> def commonprefix(args, sep='/'):
return os.path.commonprefix(args).rpartition(sep)[0]
2013-04-10 21:29:02 -07:00
>>> commonprefix(['/home/user1/tmp/coverage/test',
'/home/user1/tmp/covert/operator', '/home/user1/tmp/coven/members'])
'/home/user1/tmp'