[Python-3000] path in py3K Re: [Python-checkins] r51624 - in python/trunk/Lib: genericpath.py macpath.py ntpath.py os2emxpath.py posixpath.py test/test_genericpath.py

Jim Jewett jimjjewett at gmail.com
Sun Aug 27 04:42:02 CEST 2006


In Py3K, is it still safe to assume that a list of paths will be
(enough like) ordinary strings?

I ask because of the various Path object discussions; it wasn't clear
that a Path object should be a sequence of (normalized unicode?)
characters (rather than path components), that the path would always
be normalized or absolute, or even that it would implement the LE (or
LT?) comparison operator.

-jJ

On 8/26/06, jack.diederich <python-checkins at python.org> wrote:
> Author: jack.diederich
> Date: Sat Aug 26 20:42:06 2006
> New Revision: 51624

> Added: python/trunk/Lib/genericpath.py

> +# Return the longest prefix of all list elements.
> +def commonprefix(m):
> +    "Given a list of pathnames, returns the longest common leading component"
> +    if not m: return ''
> +    s1 = min(m)
> +    s2 = max(m)
> +    n = min(len(s1), len(s2))
> +    for i in xrange(n):
> +        if s1[i] != s2[i]:
> +            return s1[:i]
> +    return s1[:n]


More information about the Python-3000 mailing list