Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 54afb3b commit a48bf79Copy full SHA for a48bf79
1 file changed
Lib/macpath.py
@@ -46,6 +46,28 @@ def split(s):
46
return s[:colon-1], s[colon:]
47
48
49
+# Split a path in root and extension.
50
+# The extension is everything starting at the last dot in the last
51
+# pathname component; the root is everything before that.
52
+# It is always true that root + ext == p.
53
+
54
+def splitext(p):
55
+ root, ext = '', ''
56
+ for c in p:
57
+ if c == ':':
58
+ root, ext = root + ext + c, ''
59
+ elif c == '.':
60
+ if ext:
61
+ root, ext = root + ext, c
62
+ else:
63
+ ext = c
64
+ elif ext:
65
+ ext = ext + c
66
67
+ root = root + c
68
+ return root, ext
69
70
71
# Split a pathname into a drive specification and the rest of the
72
# path. Useful on DOS/Windows/NT; on the Mac, the drive is always
73
# empty (don't use the volume name -- it doesn't have the same
0 commit comments