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

Eric Snow ericsnowcurrently at gmail.com
Tue Oct 9 01:45:39 CEST 2012


On Mon, Oct 8, 2012 at 4:47 PM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Andrew McNabb wrote:
>>
>> Since this really is a matter of personal taste, I'll end my
>> participation in this discussion by voicing support for Nick Coghlan's
>> suggestion of a `join` method, whether it's named `join` or `append` or
>> something else.
>
>
> I'd prefer 'append', because
>
>    path.append("somedir", "file.txt")
>
> is pretty self-explanatory, whereas
>
>    path.join("somedir", "path.txt")
>
> looks confusingly similar to
>
>    s.join("somedir", "path.txt")
>
> where s is a string, but has very different semantics.

As Nick noted, the problem is that append() conflicts with
MutableSequence.append().  If someone subclasses Path and friends to
act like a list then it complicates the situation.  In my mind the
name should be one that is not already in use by strings or sequences.

-eric



More information about the Python-ideas mailing list