python - what does this operator means in django `reduce(operator.and_, query_list)` -
i reading questions
constructing django filter queries dynamically args , kwargs
i not able operator do
filter(reduce(operator.or_, argument_list))
or this
filter(reduce(operator.and_, query_list))
filter regular method of django model manager, there nothing explain.
reduce built-in function similar code below:
def reduce(func, items): result = items.pop() item in items: result = func(result, item) return result where func user defined function.
operator.or_ python standard library function wraps or operator. similar code:
def or_(a, b): return | b for example:
reduce(operator.or_, [false, false, true]) will return true.
in example context, or , and operators overloaded , therefore should return new query combined of smaller parts concatenated or or and operator.
Comments
Post a Comment