Open this example in the interactive library
Source code
from pathlib import PurePosixPath
p = PurePosixPath('/reports/annual.csv')
print(p.name, p.stem, p.suffix)Sample output
annual.csv annual .csv

Inspect path components. A self-contained example using the Python standard library.
Open this example in the interactive library
from pathlib import PurePosixPath
p = PurePosixPath('/reports/annual.csv')
print(p.name, p.stem, p.suffix)annual.csv annual .csv