[Python-Dev] / as path join operator

Adam Olsen rhamph at gmail.com
Sat Jan 28 06:49:50 CET 2006


On 1/27/06, Jason Orendorff <jason.orendorff at gmail.com> wrote:
> On 1/25/06, Stephen J. Turnbull <stephen at xemacs.org> wrote:
> > I think it's logical to expect that
> >     Path('home') / 'and/or'
> > points to a file named "and/or" in directory "home", not to a file
> > named "or" in directory "home/and".
>
> This makes no sense whatsoever.  Ergo, by reductio ad absurdum, paths
> are strings.

It makes perfect sense to me.  However, since posix doesn't permit '/'
in file names I would expect it to emit an error:

Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.

However, I'm not sure if the error be emitted when the Path is
created, or when it's passed to open().  The former implies a set of
OS-specific Path classes, and would allow subclassing from str.  The
latter allows (but does not require) a single universal Path class,
and that would prohibit subclassing from str (because you need a
higher-level representation to store path segments before converting
them to a platform-specific format.)

I'm -0 on subclassing str in the shortterm and -1 on it in the
longterm.  It's cruft and not something we want to be stuck with.

--
Adam Olsen, aka Rhamphoryncus


More information about the Python-Dev mailing list