[Python-ideas] os.path.commonpath()

Eli Bendersky eliben at gmail.com
Wed Nov 7 02:01:50 CET 2012


> On 6 Nov, 2012, at 16:27, Serhiy Storchaka <storchaka at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20121106/728496a4/attachment.html>


More information about the Python-ideas mailing list