Kaydet (Commit) 73e122f5 authored tarafından Guido van Rossum's avatar Guido van Rossum

Fix splitext() to go up to the last dot, not the first.

üst 76f587b7
...@@ -83,16 +83,21 @@ def split(p): ...@@ -83,16 +83,21 @@ def split(p):
# Split a path in root and extension. # Split a path in root and extension.
# The extension is everything starting at the first dot in the last # The extension is everything starting at the last dot in the last
# pathname component; the root is everything before that. # pathname component; the root is everything before that.
# It is always true that root + ext == p. # It is always true that root + ext == p.
def splitext(p): def splitext(p):
root, ext = '', '' root, ext = '', ''
for c in p: for c in p:
if c in '/\\': if c in ['/','\\']:
root, ext = root + ext + c, '' root, ext = root + ext + c, ''
elif c == '.' or ext: elif c == '.':
if ext:
root, ext = root + ext, c
else:
ext = c
elif ext:
ext = ext + c ext = ext + c
else: else:
root = root + c root = root + c
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment