[Python-Dev] [Python-3000] Unipath package

Mike Orr sluggoster at gmail.com
Mon Jan 29 00:08:55 CET 2007


On 1/28/07, Mike Orr <sluggoster at gmail.com> wrote:
> >  Passing an absolute foreign path is an error, because there's no sane way
> > to interpret "C:\\" on Posix or "/" on Windows.
> >  There is in fact a very sane way to interpret "/" on Windows: the root
> > directory of the "current" drive.  It's equivalent to "\".
>
> That's one way to do it, but whether Unipath should presume this is
> what the programmer wants is another issue.  One can make an argument
> either way.

The issue is that *maybe* the programmer wants to copy "/etc/mailcap"
on his Posix filesystem to "\etc\mailcap" on his Windows drive, but
should we assume this since \etc does not have the special status on
Windows that /etc does on Unix?  Maybe we should raise an exception
because the programmer intended to copy it somewhere else and forgot
something.  Nothing wrong with forcing him to say, "Yes, I really mean
'\'."

As for Posix-format paths in config files that should be translated to
the native NT, that sounds straightforward.  These paths should be
relative to some platform-specific root, because "C:/etc/mailcap" is
certainly not the path you intend to use on all platforms.  (Unix
would put it in the current directory, wherever that might be.)  You
can create a Path("/foo/bar") on NT and use it.  The only thing you
can't do is:

    p = Path( PosixPath("/foo/bar") )   # Illegal for absolute paths
if Path != PosixPath.

-- 
Mike Orr <sluggoster at gmail.com>


More information about the Python-Dev mailing list