[Python-Dev] The path module PEP (original) (raw)

Ian Bicking ianb at colorstudy.com
Thu Jan 26 05:35:23 CET 2006


Gustavo J. A. M. Carneiro wrote:

On a slightly different subject, regarding path / path, I think it feels much more natural path + path. Path.join is really just a string concatenation, except that it adds a path separator in the middle if necessary, if I'm not mistaken.

No, it isn't, which maybe is why / is bad. os.path.join(a, b) basically returns the path as though b is interpreted to be relative to a. I.e., os.path.join('/foo', '/bar') == '/bar'. Not much like concatenation at all. Plus string concatenation is quite useful with paths, e.g., to add an extension.

If a URI class implemented the same methods, it would be something of a question whether uri.joinpath('/foo/bar', 'baz') would return '/foo/baz' (and urlparse.urljoin would) or '/foo/bar/baz' (as os.path.join does). I assume it would be be the latter, and urljoin would be a different method, maybe something novel like "urljoin".

-- Ian Bicking | ianb at colorstudy.com | http://blog.ianbicking.org



More information about the Python-Dev mailing list