u = kvm.users.get(id=userid) for perm in u.permissions.list(): udc = perm.get_data_center() if udc: globaldc = kvm.datacenters.get(id=udc.get_id()) if globaldc.get_name() == dc: perm.delete()The perm.delete() call is not correct and you need to put the following two lines: