pathlib

Stdlib — OS/FilePython 3.4+Beginner

Object-oriented filesystem paths (modern replacement for os.path)

Quick Info

Documentation
Official Docs
Python Version
3.4+
Dependencies
None — Python Standard Library
Install
Included with Python

Learn by Difficulty

Quick Example

python
from pathlib import PurePosixPath as Path

# Path operations (using PurePosixPath for Pyodide compatibility)
p = Path("/home/user/documents/file.txt")
print(f"Name: {p.name}")
print(f"Stem: {p.stem}")
print(f"Suffix: {p.suffix}")
print(f"Parent: {p.parent}")
print(f"Parts: {p.parts}")

The pathlib module is part of Python's standard library. Object-oriented filesystem paths (modern replacement for os.path).

Try in Playground

Tags

stdlibfile-iopathmodern

Related Items