paths = { name: Path('/foo/bar/name/'), ... } def ensure_path(name): p = paths[name] p.mkdir(exist_ok=True) return p __getattr__ = ensure_path