os.path.join("/a","/b")

Siggy Brentrup bsb at winnegan.de
Thu Feb 22 18:01:29 EST 2001


matt at mondoinfo.com (Matthew Dixon Cowles) writes:

> 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.

Consult the library reference, it says "if any component is an
absolute path ..."

Thx
  Siggy





More information about the Python-list mailing list