]> granicus.if.org Git - python/commitdiff
Fix splitext() to go up to the last dot, not the first.
authorGuido van Rossum <guido@python.org>
Wed, 22 Jan 1997 00:17:26 +0000 (00:17 +0000)
committerGuido van Rossum <guido@python.org>
Wed, 22 Jan 1997 00:17:26 +0000 (00:17 +0000)
Lib/ntpath.py

index d67e856c8d3a7d9786ac2d22c108da0388e8fa4d..6a77ec849be98f9f15600974343d0453ecd97c80 100644 (file)
@@ -83,16 +83,21 @@ def split(p):
 
 
 # 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.
 # It is always true that root + ext == p.
 
 def splitext(p):
        root, ext = '', ''
        for c in p:
-               if c in '/\\':
+               if c in ['/','\\']:
                        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
                else:
                        root = root + c