def try_delete(file_or_dir):
    "Try to delete a file or directory."
    try:
        if path.isfile(file_or_dir):
            remove(file_or_dir)
        elif path.isdir(file_or_dir):
            rmdir(file_or_dir)
    except EnvironmentError:
        pass
    return file_or_dir
Try to delete a file or directory.
recipes/Python/577670_Destroying_Directories/recipe-577670.py