[Python-Dev] Alternative path suggestion

Paul Moore p.f.moore at gmail.com
Thu May 4 16:18:29 CEST 2006


On 5/4/06, Nick Coghlan <ncoghlan at gmail.com> wrote:
> My inclination was to have a PlatformPath subclass that accepted 'os', 'sep'
> and 'extsep' keyword arguments to the constructor, and provided the
> appropriate 'sep' and 'extsep' attributes (supplying 'os' would just be a
> shortcut to avoid specifying the separators explicitly).
>
> That way the main class can avoid being complicated by the relatively rare
> need to operate on another platform's paths, while still supporting the ability.

You ought to have predefined classes for the standard OSes. Expecting
people to know the values for sep and extsep seems unhelpful.

In fact, unless you expect to support the os.path interface forever,
as well as the new interface,  I'd assume there would have to be
internal WindowsPath and PosixPath classes anyway - much like the
current ntpath and posixpath modules. So keeping that structure, and
simply having

if os.name == 'posix':
    Path = PosixPath
elif os.name == 'nt':
    Path = WindowsPath
... etc

at the end, would seem simplest.

(But all the current proposals seem to build on os.path, so maybe I
should assume otherwise, that os.path will remain indefinitely...)

Paul.


More information about the Python-Dev mailing list