summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-10-07 14:48:23 (GMT)
committerGuido van Rossum <guido@python.org>1997-10-07 14:48:23 (GMT)
commitae590db3ce8cd583f1f14fbb498f45d095b6d262 (patch)
treee4ce67ee23d788cf6c944d1948ec7ea8d83033c7 /Lib
parentabfdd706654cd9610bcc5c9c62a22571317e7752 (diff)
downloadcpython-ae590db3ce8cd583f1f14fbb498f45d095b6d262.zip
cpython-ae590db3ce8cd583f1f14fbb498f45d095b6d262.tar.gz
cpython-ae590db3ce8cd583f1f14fbb498f45d095b6d262.tar.bz2
Fix join to support multiple arguments.
(Why isn't this file identical to ntpath.py?)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/dospath.py21
1 files changed, 12 insertions, 9 deletions
diff --git a/Lib/dospath.py b/Lib/dospath.py
index 725b381..73e6377 100644
--- a/Lib/dospath.py
+++ b/Lib/dospath.py
@@ -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