Pathlib parts (basename)
- basename
- parts
from pathlib import Path
this = Path(__file__)
print(this)
print(this.parts[-1]) # (basename)
print(this.parts[0]) # /
print(this.parts) # (each part of the path)
Press ← or → to navigate between chapters
Press S or / to search in the book
Press ? to show this help
Press Esc to hide this help
from pathlib import Path
this = Path(__file__)
print(this)
print(this.parts[-1]) # (basename)
print(this.parts[0]) # /
print(this.parts) # (each part of the path)