import importlib.resources as ir # returning the Traversable for a data directory 'data' returns a PosixPath if # there is a data/__init__.py and MultiplexedPath object otherwise. trav_data = ir.files('data') print(f"Traverse data: {trav_data} ({type(trav_data)})") # iterdir iterates over the files in the directory but doesn't give you a # reference to the directory itself. for x in trav_data.iterdir(): print(f"X: {x} ({type(x)})")