os.path.join("/a","/b")
Joshua Marshall
jmarshal at mathworks.com
Thu Feb 22 17:25:35 EST 2001
Matthew Dixon Cowles <matt at mondoinfo.com> wrote:
> I was a little surprised today to notice that
> os.path.join("/a","/b") returns '/b'
> (os.path is posixpath in this case of course) while
> os.path.join("/a/","b") returns "/a/b"
> which I expected from both. Poking back into my dusty archives, I find
> that it has been that way since at least 1.4 so I presume that it's a
> feature but I'll be darned if I can figure out the logic. It sure
> doesn't seem to have much to do with joining. The module's docstring
> just says "Join two or more pathname components, inserting '/' as
> needed".
> If someone could explain the logic to me, I'd be grateful.
> Regards,
> Matt
It's as if you cd to directory "/a" and reference "/b". Since "/b" is
an absolute path, the current directory is ignored.
More information about the Python-list
mailing list