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

Greg Ewing greg.ewing at canterbury.ac.nz
Tue Oct 9 09:35:05 CEST 2012


T.B. wrote:
> A small problem I see with 'add' (and with 
> 'append') is that the outcome of adding (or appending) an absolute path 
> is too surprising, unlike with the 'join' or 'joinpath' names.

I don't think it's any less surprising with "join" -- when
you join two things, you just as much expect both of them to
be part of the result.

There doesn't seem to be any concise term that encompasses
all the nuances of the operation. Using an arbitrarily chosen
operator would at least have the advantage of sidestepping
the whole concern.

Programmer 1: "Hey, what does ^ do on path objects?"

Programmer 2: "It concatenates them with a path separator
between, except when the second one is an absolute path,
in which case it just returns the second one."

Programmer 1: "That's so obscure. Why didn't they just
define a concat_with_pathsep_or_second_if_absolute()
method... oh, wait, I think I see..."

-- 
Greg



More information about the Python-ideas mailing list