pathlib

pathlib represents file paths as Path objects, independent of the operating system. The / operator joins paths, and the methods exists(), mkdir(), iterdir(), glob(), read_text() replace many os.path functions. It makes code more readable and portable.

Example

from pathlib import Path
for f in Path('data').glob('*.csv'):
    print(f.name)

Related concepts

The whole glossary