Just Use Pathlib ━━━━━━━━━━━━━━━━ Pathlib is an amazing cross-platform path tool. Date: September 26, 2019 Pathlib is an amazing cross-platform path tool. Import ────── [code] from pathlib import Path Create path object ────────────────── Current Directory [code] cwd = Path('.').absolute() Users Home Directory [code] home = Path.home() module directory [code] module_path = Path(__file__) Others Let’s create a path relative to our current module. [code] data_path = Path(__file__) / 'data' Check if files exist ──────────────────── Make Directories ──────────────── [code] data_path.mkdir(parents=True, exists_ok=True) rename files ──────────── [code] Path(data_path /'example.csv').rename('real.csv') List files ────────── Glob Files ────────── [code] data_path.glob('*.csv') recursively [code] data_path.rglob('*.csv') Write ───── [code] Path(data_path / 'meta.txt').write_text(f'created on {datetime.datetime.today()})