[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-dev
Subject:    Re: [Python-Dev] The path module PEP
From:       Paul Moore <p.f.moore () gmail ! com>
Date:       2006-01-27 10:16:09
Message-ID: 79990c6b0601270216x2c43449cj534427f7a8f5234c () mail ! gmail ! com
[Download RAW message or body]

On 1/26/06, Stefan Rank <stefan.rank@ofai.at> wrote:
> on 26.01.2006 14:15 Paul Moore said the following:
> [snip]
> >
> > Also note that my example Path("C:", "Windows", "System32") above is
> > an *absolute* path on Windows. But a relative (albeit stupidly-named
> > :-)) path on Unix. How would that be handled?
>
> wrong, Path("C:", "Windows", "System32") is a relative path on windows.
> see below.

Hmm, relative to the CWD on C: is a valid concept, and that is a
potential meaning. I hadn't thought of that.

> > Not that os.path gets it perfect:
> >
> > Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] on win32
> > Type "help", "copyright", "credits" or "license" for more information.
> >>>> import os
> >>>> os.path.join("C:", "Windows", "System32")
> > 'C:Windows\\System32'
> >>>> os.path.join(".", os.path.join("C:", "Windows", "System32"))
> > '.\\C:Windows\\System32'
> >
>
> this is misleading. observe::
>
>   In [1]: import os
>
>   In [2]: os.path.join(".", os.path.join("C:", "Windows", "System32"))
>   Out[2]: '.\\C:Windows\\System32'
>
> but::
>
>   In [3]: os.path.join(".", os.path.join("C:\\", "Windows", "System32"))
>   Out[3]: 'C:\\Windows\\System32'
>
>
> The second example uses an absolute path as second argument, and as
> os.path.join should do, the first argument is discarded.
>
> The first case is arguably a bug, since, on windows, C:Windows\System32
> is a path relative to the *current directory on disk C:*
> If the cwd on C: would be C:\temp then C:Windows\System32 would point to
> C:\temp\Windows\System32
>
> The problem is that Windows has a cwd per partition...
> (I cannot even guess why ;-)

Thanks for the clarification, you are right in your analysis. However,
it doesn't really affect my main point, which was that there should be
no such thing as a relative Path (please note - I say "Path" here, to
refer to the new Path object, as opposed to the general concept of an
OS file path).

[...]
> > Arguably, Path objects should always maintain an absolute path - there
> > should be no such thing as a relative Path. So you would have
>
> you realise that one might need and/or want to represent a relative path?

Absolutely. But not a Path (see distinction above).

Aaron Bingham's analogy with time/timedelta applies well here.
Relative paths, like relative times, have their own special semantics,
which deserve to be addressed in a separate class.

You argue that time is "merely" a timedelta with a fixed start point.
I'd disagree - the key point with timedeltas is that they need careful
handling (DST issues, for example) _depending upon precisely what they
are added to_ - these issues are avoided by the time type exactly
because it has a constant base. In exactly the same way, absolute
paths have simpler semantics precisely because they are absolute.

Paul.
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/python-dev%40progressive-comp.com
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic