Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
a89b1bad
Commit
a89b1bad
authored
Sep 01, 1995
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rationalized os.path.split() so split "/a/" yields "/a", ""
parent
6655c4e2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
13 deletions
+7
-13
Lib/posixpath.py
Lib/posixpath.py
+7
-13
No files found.
Lib/posixpath.py
View file @
a89b1bad
...
...
@@ -32,21 +32,15 @@ def join(a, b):
# Split a path in head (everything up to the last '/') and tail (the
# rest). If the original path ends in '/' but is not the root, this
# '/' is stripped. After the trailing '/' is stripped, the invariant
# join(head, tail) == p holds.
# The resulting head won't end in '/' unless it is the root.
# rest). If the path ends in '/', tail will be empty. If there is no
# '/' in the path, head will be empty.
# Trailing '/'es are stripped from head unless it is the root.
def
split
(
p
):
if
p
[
-
1
:]
==
'/'
and
p
<>
'/'
*
len
(
p
):
while
p
[
-
1
]
==
'/'
:
p
=
p
[:
-
1
]
head
,
tail
=
''
,
''
for
c
in
p
:
tail
=
tail
+
c
if
c
==
'/'
:
head
,
tail
=
head
+
tail
,
''
if
head
[
-
1
:]
==
'/'
and
head
<>
'/'
*
len
(
head
):
import
string
i
=
string
.
rfind
(
p
,
'/'
)
+
1
head
,
tail
=
p
[:
i
],
p
[
i
:]
if
head
and
head
<>
'/'
*
len
(
head
):
while
head
[
-
1
]
==
'/'
:
head
=
head
[:
-
1
]
return
head
,
tail
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment