From cb3ad84fdaa677b179639000b086030b17b0a7e1 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Wed, 8 Jul 2026 14:43:30 +0200 Subject: [PATCH] misc.is_multi_value(): Add function Add a function that allows to test one expression if a value can be iterated over without being a string or bytes. Signed-off-by: Jan Lindemann --- src/python/jw/util/misc.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/python/jw/util/misc.py b/src/python/jw/util/misc.py index 94418ad..7c4959a 100644 --- a/src/python/jw/util/misc.py +++ b/src/python/jw/util/misc.py @@ -195,6 +195,9 @@ def multi_regex_edit(spec, strings: Iterable[str]) -> list[str]: # export raise Exception('Invalid command in multi_regex_edit(): {}'.format(str(cmd))) return strings +def is_multi_value(obj: Any) -> bool: # export + return isinstance(obj, Iterable) and not isinstance(obj, (str, bytes)) + def dump(prio: int, objects: Iterable, *args, **kwargs) -> None: # export caller = log.get_caller_pos(kwargs = kwargs) log.slog(prio, ",---------- {}".format(' '.join(args)), caller = caller)