[Python-ideas] PEP 428 - object-oriented filesystem paths
ncoghlan at gmail.com
Mon Oct 8 20:39:23 CEST 2012
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.
They're certainly not "super" anything, any more than a subdirectory
is really a superdirectory (which is what you appear to be arguing).
> Okay, I'll grant you that we'll probably never get a consensus on
> operators + versus / but I really don't understand why you think that
> p.join is unsuitable for a method which joins path components.
"p.join(r)" has exactly the same problem as "p + r": pass in a string
to a function expecting a path object and you get data corruption
instead of an exception. When you want *different* semantics, then
ducktyping is your enemy and it's necessary to take steps to avoid it,
include changing method names and avoiding some operators.
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-ideas