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

Paul Moore p.f.moore at gmail.com
Mon Oct 8 20:47:43 CEST 2012


On 8 October 2012 19:39, Nick Coghlan <ncoghlan at gmail.com> wrote:
>> 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.

Ah, OK. I understand your objection now.

I concede that Path.join() is a bad idea based on this.
I still don't like subpath() though.
And pathjoin() is too likely to be redundant in real code:

temp_path = Path(tempfile.mkdtemp())
generated_file = temp_path.pathjoin('data_extract.csv')

I can't think of a better term, though :-(

Paul



More information about the Python-ideas mailing list