Safe rmdir (non-recursive) which doesn't throw if the directory is not empty.

def rmdir(path):
    """Safe rmdir (non-recursive) which doesn't throw if the directory is not empty."""
    try:
        os.rmdir(path)
    except OSError as exc:
        print(str(exc))