From 5c9e46027b982c0637c17e0699d2eaece188ef75 Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Tue, 5 Jun 2007 15:05:31 +0000 Subject: [PATCH] Try to make the utils/listop functions return something sensible with empty input. - Legacy-Id: 233 --- ietf/utils/listop.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ietf/utils/listop.py b/ietf/utils/listop.py index 7a446969e..bd9e0c149 100644 --- a/ietf/utils/listop.py +++ b/ietf/utils/listop.py @@ -3,11 +3,17 @@ import operator def orl(list): """ Return the "or" of every element in a list. Used to generate "or" queries with a list of Q objects. """ - return reduce(operator.__or__, list) - + if list: + return reduce(operator.__or__, list) + else: + return None + def flattenl(list): """ Flatten a list one level, e.g., turn [ ['a'], ['b'], ['c', 'd'] ] into [ 'a', 'b', 'c', 'd' ] """ - return reduce(operator.__concat__, list) + if list: + return reduce(operator.__concat__, list) + else: + return [] \ No newline at end of file