On this page
posixpath.splitext
Prev: posixpath.splitdrive | Up: posixpath | Next: posixpath.splitroot
Rel: posixpath.abspath, posixpath.basename, posixpath.commonpath, posixpath.commonprefix
Ref: docs.python.org — posixpath.splitext
Tags: #public #python3 #stdlib #posixpath
Import
import posixpath
from posixpath import splitext
Signature & Overview
posixpath.splitext(p)
Split the extension from a pathname.
Usage
import posixpath
assert posixpath.splitext('/a/archive.tar.gz') == ('/a/archive.tar', '.gz')
Gotchas
- Splits only the final suffix and leaves dotfiles (
'.gitignore') intact.
REPL Inspect
from posixpath import splitext
help(splitext)
Linked from
Related notes
- tuts/python3/stdlib_module/posixpath/splitdrive Linked here; links to this page; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/splitroot Linked here; links to this page; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/posixpath/abspath Linked here; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/basename Linked here; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/commonpath Linked here; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/commonprefix Linked here; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/dirname shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/exists shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/expanduser shared tags: #posixpath, #stdlib