datatracker/ietf/utils/listop.py
Henrik Levkowetz cf20093762 * Moved utility functions into utils/ directory, and started breaking out
utilities into separate files.
 * Added a log() function in ietf/utils.  It uses syslog, but adds some
   information about where it was called from.
 - Legacy-Id: 130
2007-05-11 15:48:45 +00:00

14 lines
367 B
Python

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)
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)