[Python-ideas] PEP 428: poll about the joining syntax

Steven D'Aprano steve at pearwood.info
Tue Oct 9 04:26:53 CEST 2012


Summary:

- favourite & second-favourite choices: `p.join(q)` or `p.add(q)`.

- most disliked:  `p[q]`



`p[q]`  -1: looks like indexing or key-lookup, isn't either.

`p + q`  +0: potential confusion between path component joining and 
    filename suffix appending.

`p / q`  +0: looks funny if either arg is a literal string.

`p.join(q)`:  +1: self-explanatory, suggests os.path.join, I am not 
    convinced that Nick's fears about confusing Path.join and str.join 
    will be a problem in practice.

`p.pathjoin(q)` and `p.joinpath(q)`  -1: dislike repeating the type 
    name in the method name;  also, too easy to forget which one is
    used.

`p.add(q)`  +0.5: nice and short, but not quite self-explanatory.

`p.append(q)`  -0: suggests an in-place modification.



-- 
Steven




More information about the Python-ideas mailing list