How to use Python shutil

Sometimes you want to delete a folder in Python. You know that os.rmdir() can do that for you. But then you realize it can only remove empty folders. If you want to remove the content before deleting the folder you come up with: def remove_non_empty_dir(path_to_dir): if os.path.exists(path_to_dir): files_in_dir = os.listdir(path_to_dir) for file in files_in_dir: os.remove(os.path.join(path_to_dir,…