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

Stephen J. Turnbull stephen at xemacs.org
Mon Oct 8 14:46:13 CEST 2012


Paul Moore writes:
 > On 8 October 2012 11:31, Nick Coghlan <ncoghlan at gmail.com> wrote:

 > > designing an API. "p.subpath('foo', 'bar')" looks like executable
 > > pseudocode for creating a new path based on existing one to me, unlike
 > > "p / 'foo' / 'bar'", "p['foo', 'bar']", or "p.join('foo', 'bar')".
 > 
 > Until precisely this point in your email, I'd been completely
 > confused, because I thought that p.supbath(xxx) was some sort of "is
 > xxx a subpath of p" query.

I agree with Paul on this.

If .join() doesn't work for you, how about .append() for adding new
path components at the end, vs. .suffix() for adding an extension to
the last component?

(I don't claim Paul would agree with this next, but as long as I'm
here....)  I really think that the main API for paths should be the
API for sequences specialized to "sequence of path components", with a
subsidiary set of operations for common textual manipulations applied
to individual components.






More information about the Python-ideas mailing list