[Python-ideas] PEP 428 - object-oriented filesystem paths

Antoine Pitrou solipsis at pitrou.net
Mon Oct 8 20:51:39 CEST 2012


On Tue, 9 Oct 2012 00:09:23 +0530
Nick Coghlan <ncoghlan at gmail.com> wrote:
> On Mon, Oct 8, 2012 at 11:53 PM, Steven D'Aprano <steve at pearwood.info> wrote:
> >> "p.subpath('foo', 'bar')" looks like executable
> >> pseudocode for creating a new path based on existing one to me,
> >
> >
> > That notation quite possibly goes beyond unintuitive to downright
> > perverse. You are using a method called "subpath" to generate a
> > *superpath* (deeper, longer path which includes p as a part).
> 
> Huh? It's a tree structure. A subpath lives inside its parent path,
> just as subnodes are children of their parent node. Agreed it's not a
> widely used term though - it's a generalisation of subdirectory to
> also cover file paths.

Well, it's a "subpath", except when it isn't:

  >>> p = Path('a')
  >>> p.join('/b')
  PosixPath('/b')

I have to admit I didn't understand what your meant by "subpath" until
you explained that it was another name for "join". It really don't
think it's a good name. child() would be a good name, except for the
case above where you join with an absolute path (above). Actually,
child() could be a variant of join() which wouldn't allow for absolute
arguments.

Regards

Antoine.


-- 
Software development and contracting: http://pro.pitrou.net





More information about the Python-ideas mailing list