Convert between Windows style paths and POSIX style paths

Noah noah at noah.org
Fri Jul 11 17:25:26 EDT 2003


Peter Hansen <peter at engcorp.com> wrote in message news:<3F0DE565.1CEA39C6 at engcorp.com>...

> You can use forward slashes in paths under Win32, except at the
> command prompt.
> 
> Even if you switch to use all forward slashes, however, what do
> you plan to do about drive letters?  There is no obvious mapping
> to anything under POSIX, I think.  Are you planning on disallowing
> paths that go anywhere but the current drive under NT?
> -Peter

I had forgotten that NT supports forward slashes.
My only concern is that some of the config file values are
set programatically and I use os.path.join everywhere, so if the
config file is modified when running under Windows then the paths
will get \ separators and that will confuse the UNIX side.
I think I will still need something to ensure that the paths
are consistent... Hmmm... I wonder how evil it would be to simply set
os.sep = '/' when I initialize my application. I wonder if I will be
angering the dark lords of Microsoft by doing this.

I was going to simply remove the drive letter, so, yes, that would
disallow paths other than the curent drive. I might also map the drive
letters to a point on the POSIX path or I might do it Cygwin style
where C: becomes /cygdrive/c/.




More information about the Python-list mailing list