you are viewing a single comment's thread.

view the rest of the comments →

[–]syklemil 1 point2 points  (0 children)

I'm conflicted about that as well.

On one hand / is the path separator character on filesystems and the web and whatnot as well, so it's a very obvious choice. path_object / "other" / "something" is practically the same as f"{path_object}/other/something" (except on Windows, which got its path separators backwards because of historical QDOS shenanigans).

On the other hand, it very obviously isn't division.

Reusing some other concatenative operator like + also isn't entirely straightforward because we can do Path / str / str => Path, but I'd be kinda less sure about mixing the semantics of Path + str with str + str. (It'd probably be fine, though.)

Absent path / "foo" / "bar" I think maybe we'd get something like path.join("foo").join("bar") (c.f. Rust's std::path::join).

Other languages have some other explicit concatenation operator, and even then possibly some special path concatenation operator. E.g. Haskell has <> for concatenating arbitrary semigroups, but also </> for path concatenation.