PRE-PEP: new Path class

Gerrit Holl gerrit at
Tue Jan 6 20:52:40 CET 2004

> > >7) Should the various gettime methods return Datetime
> > >objects.

[John Roth]
> > >Of course.

I was hasitating, because of the backwards-compability, but this should
not be a reason not to make things better, of course (TV isn't backward
compatible with radio either ;)

[Mike C. Fletcher]
> > What are we doing for Python 2.2 then?  I agree with the principle, but
> > we should likely have a fallback when datetime isn't available.

[John Roth]
> Do we care? If this is going into Python, it will be in 2.4 at the
> earliest, with a possible addon to a late 2.3 release. I don't see
> it going into 2.2 at all, although a backwards version would
> be nice.

If the PEP will be finished and may be accepted, I think that the
roadmap of introducing the feature will be like sets: In 2.4, it's a
library, and if it's succesful/popular, it may become a builtin in 2.5.

> > Path commonprefix are different operations from str commonprefix.  Paths
> > should only accept entire path-segments (names) as being equal, while
> > strings should accept any set of characters:
> >
> >     '/this/that/those/them'
> >     '/this/thatly/those/them'
> >
> > should see '/this/' as the commonprefix for the paths, not '/this/that'.

In should... it doesn't seem to do so currently.

> Good point if you're thinking of heterogenous collections. If you're
> thinking (as I am) that an object can represent a directory, then it
> seems like a singularly useless method.

The only place where I can think of a use is a tarfile/zipfile. For a
path, it means nothing. It can be useful but since it needs multiple
paths, it can't be a method. The only thing I can think of is a
classmethod, a constructor, but I don't really like the idea much.

> > >13) chdir, chmod, etc?
> > >
> > >No. This has nothing to do with pathname.

Is p.chdir() better or worse than chdir(p)?
The latter reads better, but that may be because we're used to it.
But on the other hand, that may be a convincing argument just as well :)

> > chdir should accept a path, otherwise doesn't seem like it
> > should be a method.
> If the path object describes a directory, then I'd see
> a .chdir() method as useful. Otherwise, it belongs
> somewhere else, although I don't have a clue where
> at the moment.

I think there should be no distinction between files and directories,
and that p.chdir() for a non-directory should raise the same exception
as currently (OSError Errno 20).


27. If a chieftain or man be caught in the misfortune of the king
(captured in battle), and if his fields and garden be given to another and
he take possession, if he return and reaches his place, his field and
garden shall be returned to him, he shall take it over again.
          -- 1780 BC, Hammurabi, Code of Law
Asperger's Syndrome - a personal approach:

More information about the Python-list mailing list