From 2019194af60669b988d59770e1095e8703ec20c6 Mon Sep 17 00:00:00 2001 From: Felix Kleinert <f.kleinert@fz-juelich.de> Date: Mon, 23 Mar 2020 16:59:44 +0100 Subject: [PATCH] update pop_list fuction to behave like dict_pop --- src/helpers.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/helpers.py b/src/helpers.py index cfbaa79d..f472a7ca 100644 --- a/src/helpers.py +++ b/src/helpers.py @@ -201,19 +201,17 @@ def float_round(number: float, decimals: int = 0, round_type: Callable = math.ce return round_type(number * multiplier) / multiplier -def dict_pop(dict: Dict, pop_keys): - pop_keys = to_list(pop_keys) - return {k: v for k, v in dict.items() if k not in pop_keys} - - def list_pop(list_full: list, pop_items): pop_items = to_list(pop_items) if len(pop_items) > 1: return [e for e in list_full if e not in pop_items] else: - list_pop = list_full.copy() - list_pop.remove(pop_items[0]) - return list_pop + l_pop = list_full.copy() + try: + l_pop.remove(pop_items[0]) + except ValueError: + pass + return l_pop def dict_pop(dict_orig: Dict, pop_keys): -- GitLab