On Mon, 18 Jul 2011 14:30:51 -0400, Lars T. Kyllingstad <public@kyllingen.nospamnet> wrote:

On Mon, 18 Jul 2011 13:26:08 -0400, Steven Schveighoffer wrote:

On Sun, 17 Jul 2011 18:24:30 -0400, Andrej Mitrovic
<andrej.mitrov...@gmail.com> wrote:

On 7/17/11, Lars T. Kyllingstad <public@kyllingen.nospamnet> wrote:
- Should I add toNativePath(), which replaces '/' with '\' on Windows
and
vice versa on POSIX?

Actually I withdraw that feature request. Some tools will work with
only forward slashes, others only backward slashes, but this is
regardless of what platform they're on.

E.g. some tools don't work with forward slashes, while GIT doesn't work
with backward slashes when running on Windows.

I think .replace(r"\", "/") and .replace("/", r"\") are good enough,
but maybe an alias to each version wouldn't be bad. E.g.
"toForwardSlash" and "toBackslash". It's not hard to define this in our
own code, so it's not really a feature request.


Hum... I wonder if normalize should do this...

Is normalize supposed to create a canonical path?  If so, then this
needs to happen.

normalize does this on Windows, where '/' is also a directory separator,
but not on POSIX, where '\' is an ordinary filename character.

I am not entirely sure what the exact definition of "canonical path" is,
but according to some it entails resolving symlinks.  normalize does not
do this, but it does everything else:

  - resolves . and .. to the extent possible
  - collapses redundant directory separators
  - changes '/' to '\' on Windows

OK, this is what I meant. By canonical path, I mean I should be able to take two paths that point to the same filename and normalize should output the same string for both.

I agree that the posix version should not replace \ with /, since that's a Windows specific issue.

I realize there are some limitations when all you are doing is string manipulation. For example ~steves/blah resolves to the canonical path /home/steves/blah. Same thing with symlinks.

I guess normalize is the best term for it, don't want to confuse it with full canonical.

-Steve

Reply via email to