diff options
author | Birte Kristina Friesel <birte.friesel@uos.de> | 2024-01-11 08:24:03 +0100 |
---|---|---|
committer | Birte Kristina Friesel <birte.friesel@uos.de> | 2024-01-11 08:24:03 +0100 |
commit | 325bd733f2d1af8ed861d865d24cbad98b552007 (patch) | |
tree | 209258b406dfe7bde2fc244db8da5b5c1d2569b1 /lib | |
parent | 4fd9891155a0e01029c0d95a54737d1da86e0ffd (diff) |
I need more coffee
Diffstat (limited to 'lib')
-rw-r--r-- | lib/utils.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/utils.py b/lib/utils.py index 8fb1f47..40d8b69 100644 --- a/lib/utils.py +++ b/lib/utils.py @@ -219,6 +219,24 @@ def remove_index_from_tuple(parameters, index): return (*parameters[:index], *parameters[index + 1 :]) +def remove_indexes_from_tuple(parameters, indexes): + """ + Remove the elements at `indexes` from tuple `parameters`. + + :param parameters: tuple + :param indexes: list or tuple: indexes of element which are to be removed + :returns: parameters tuple without the elements at indexes + """ + indexes = sorted(indexes) + ret = list() + last_index = 0 + for index in indexes: + ret.extend(parameters[last_index:index]) + last_index = index + 1 + ret.extend(parameters[last_index:]) + return tuple(ret) + + def param_slice_eq(a, b, index): """ Check if by_param keys a and b are identical, ignoring the parameter at index. |