Hello,
On Sun, 24 May 2020 08:38:22 -0300
Bernardo Sulzbach
"So I implemented `PurePath.__len__` as `str(len(path))`." Sure you meant len(str(path)), right?
"Serhiy and Remi objected, because it might not be obvious that the length of the path would be the length of string." I find this _really_ unintuitive. If anything, I would expect len(p) to be the "depth" of the path, which doesn't make a lot of sense if it is not an absolute path.
Rather, number of components in a path. E.g. length of Path("../a") is 2.
It is a -1 from me because, besides what I outlined above, if you need the length of the string representation, len(str(p)) is quite short and obvious already.
I fully agree. For people who find string representation of paths to be nice, there's an obvious choice of not using pathlib in the first place, no confusion ensues. And people who choose to use pathlib, should not look for ways to cheat by conflating strings and Path objects with confusing implicit conversions (which will bite people who will need to work with such a code later). -- Best regards, Paul mailto:pmiscml@gmail.com