mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Fix join to support multiple arguments.
(Why isn't this file identical to ntpath.py?)
This commit is contained in:
parent
abfdd70665
commit
ae590db3ce
1 changed files with 11 additions and 8 deletions
|
@ -35,15 +35,18 @@ def isabs(s):
|
||||||
return s != '' and s[:1] in '/\\'
|
return s != '' and s[:1] in '/\\'
|
||||||
|
|
||||||
|
|
||||||
# Join two pathnames.
|
# Join two (or more) paths.
|
||||||
# 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):
|
def join(a, *p):
|
||||||
if isabs(b): return b
|
path = a
|
||||||
if a == '' or a[-1:] in '/\\': return a + b
|
for b in p:
|
||||||
# Note: join('x', '') returns 'x/'; is this what we want?
|
if isabs(b):
|
||||||
return a + os.sep + 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
|
# Split a path in a drive specification (a drive letter followed by a
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue