On Oct 9, 2012, at 1:18 AM, Joachim König
As has already been stated by others, paths are immutable so using them like lists is leading to confusion (and list's append() only wants one arg, so extend() might be better in that case).
But paths could then be interpreted as tuples of "directory entries" instead.
So adding a path to a path would "join" them:
pathA + pathB
and in order to not always need a path object for pathB one could also write the right argument of __add__ as a tuple of strings:
pathA + ("somedir", "file.txt")
I like it. As you pointed out, my comparison with list is inappropriate because of path's immutability. So .append() and .extend() probably don't make sense.
One could also use "+" for adding to the last segment if it isn't a path object or a tuple:
pathA + ".tar.gz"
This might be a reasonable way to appease both those who are viewing path as a special tuple and those who are viewing it as a special string. It breaks the parallel with tuple a bit, but it's clear that there are important properties of both strings and tuples that would be nice to preserve. Ryan