]> granicus.if.org Git - python/commitdiff
Fix join to support multiple arguments.
authorGuido van Rossum <guido@python.org>
Tue, 7 Oct 1997 14:48:23 +0000 (14:48 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 7 Oct 1997 14:48:23 +0000 (14:48 +0000)
(Why isn't this file identical to ntpath.py?)

Lib/dospath.py

index 725b38149520652f8796eeb15603b8a9771acf33..73e6377b4f865f9b26e62a575e10936f3266dbec 100644 (file)
@@ -35,15 +35,18 @@ def isabs(s):
        return s != '' and s[:1] in '/\\'
 
 
-# Join two pathnames.
-# Ignore the first part if the second part is absolute.
-# Insert a '/' unless the first part is empty or already ends in '/'.
-
-def join(a, b):
-       if isabs(b): return b
-       if a == '' or a[-1:] in '/\\': return a + b
-       # Note: join('x', '') returns 'x/'; is this what we want?
-       return a + os.sep + b
+# Join two (or more) paths.
+
+def join(a, *p):
+       path = a
+       for b in p:
+               if isabs(b):
+                       path = b
+               elif path == '' or path[-1:] in '/\\':
+                       path = path + b
+               else:
+                       path = path + os.sep + b
+       return path
 
 
 # Split a path in a drive specification (a drive letter followed by a