On 6 Nov, 2012, at 16:27, Serhiy Storchaka <storchaka@gmail.com> wrote:

> See http://bugs.python.org/issue10395.
>
> os.path.commonpath() should be a function which returns right longest common sub-path for specified paths (os.path.commonprefix() is completely useless for this).
>
> There are some open questions about details of *right* behavior.
>
>
>
> What should be a common prefix of '/var/log/apache2' and
> '/var//log/mysql'?

/var/log

> What should be a common prefix of '/usr' and '//usr'?

/usr

> What should be a common prefix of '/usr/local/' and '/usr/local/'?

/usr/local

> What should be a common prefix of '/usr/local/' and '/usr/local/bin'?

/usr/local

> What should be a common prefix of '/usr/bin/..' and '/usr/bin'?

/usr/bin

In all cases the path is first split into its elements, then calculate the largest common prefix of the two sets of elements, then join the elements back up again.

+1

Eli