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

Antoine Pitrou solipsis at pitrou.net
Tue Oct 9 11:43:02 CEST 2012


Nick Coghlan <ncoghlan at ...> writes:
> 
> On Tue, Oct 9, 2012 at 1:22 PM, INADA Naoki <songofacandy at ...> wrote:
> > -1 on `pathjoin`.  `Path.pathjoin` is ugly.
> > The `urljoin()` is OK because it is just a function.
> 
> Hmm, this is a *very* interesting point. *All* of the alternatives
> presented are mainly replacements for just doing this:
> 
> Path(p, q)
> 
> And if you want a partially applied version, that's just:
> 
> prefix = functools.partial(Path, p)
> 
> So perhaps the right answer for the initial API is: no method, no
> operator, just use the constructor?

Well, you would have to use either PurePath(p, q) or Path(p, q) based on whether
p is pure or concrete. Unless we make the constructor more magic and let Path()
switch to PurePath() when the first argument is a pure path. Which does sounds a
bit too magic to me (Path would instantiate something which is 
not a Path instance...).

> It does suggest a whole new class of verbs though, like "make" or "build".

They are rather vague, though.

Regards

Antoine.





More information about the Python-ideas mailing list