Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Get file name including parent folder.
import pathlib
path = pathlib.Path('home/path/to/file.txt')
root = path.parent.parent
# PosixPath('home/path')
# PosixPath('to/file.txt')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.