8000 Fix join to support multiple arguments. · python/cpython@ae590db · GitHub
[go: up one dir, main page]

Skip to content

Commit ae590db

Browse files
committed
Fix join to support multiple arguments.
(Why isn't this file identical to ntpath.py?)
1 parent abfdd70 commit ae590db

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

Lib/dospath.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,18 @@ def isabs(s):
3535
return s != '' and s[:1] in '/\\'
3636

3737

38-
# Join two pathnames.
39-
# Ignore the first part if the second part is absolute.
40-
# Insert a '/' unless the first part is empty or already ends in '/'.
41-
42-
def join(a, b):
43-
if isabs(b): return b
44-
if a == '' or a[-1:] in '/\\': return a + b
45-
# Note: join('x', '') returns 'x/'; is this what we want?
46-
return a + os.sep + b
38+
# Join two (or more) paths.
39+
40+
def join(a, *p):
41+
path = a
42+
for b in p:
43+
if isabs(b):
44+
path = b
45+
elif path == '' or path[-1:] in '/\\':
46+
path = path + b
47+
else:
48+
path = path + os.sep + b
49+
return path
4750

4851

4952
# Split a path in a drive specification (a drive letter followed by a

0 commit comments

Comments
 (0)
0