# Path: pythoscope/compat.py
# def all(iterable):
# def any(iterable):
# def sorted(iterable, compare=cmp, key=None):
#     def __init__(self, iterable, key=None):
#     def __iter__(self):
#     def next(self):
#     def _grouper(self, tgtkey):
# def samefile(file1, file2):
# class groupby(object):


import cPickle
import gc
import itertools
import operator
import os
import re
import sys
import traceback
import types
import warnings
from pythoscope.compat import groupby, set, sorted
from pythoscope.py_wrapper_object import get_wrapper_self
    from _util import _generator_has_ended
    """
    for entry in os.listdir(path):
        if os.path.isdir(os.path.join(path, entry)):
            yield entry

def findfirst(pred, seq):
    """Return the first element of given sequence that matches predicate.
    """
    for item in seq:
        if pred(item):
            return item

def flatten(lst):
    """Flatten given list.

    >>> flatten([[1, 2, 3], [4, 5], [6, 7], [8]])
    [1, 2, 3, 4, 5, 6, 7, 8]
    """
    return list(itertools.chain(*lst))

# :: [set] -> set
def union(*sets):
    """Return a union of all the given sets.
    """
    if len(sets) == 0:
        return set()
    # Since 2.6 set.union accepts multiple input iterables.
    if sys.version_info >= (2, 6):
        return set.union(*sets)
    else:

# Path: pythoscope/compat.py
# def all(iterable):
# def any(iterable):
# def sorted(iterable, compare=cmp, key=None):
#     def __init__(self, iterable, key=None):
#     def __iter__(self):
#     def next(self):
#     def _grouper(self, tgtkey):
# def samefile(file1, file2):
# class groupby(object):


# Path: pythoscope/util.py
import cPickle
import gc
import itertools
import operator
import os
import re
import sys
import traceback
import types
import warnings
from pythoscope.compat import groupby, set, sorted
from pythoscope.py_wrapper_object import get_wrapper_self
    from _util import _generator_has_ended

    """
    for entry in os.listdir(path):
        if os.path.isdir(os.path.join(path, entry)):
            yield entry

def findfirst(pred, seq):
    """Return the first element of given sequence that matches predicate.
    """
    for item in seq:
        if pred(item):
            return item

def flatten(lst):
    """Flatten given list.

    >>> flatten([[1, 2, 3], [4, 5], [6, 7], [8]])
    [1, 2, 3, 4, 5, 6, 7, 8]
    """
    return list(itertools.chain(*lst))

# :: [set] -> set
def union(*sets):
    """Return a union of all the given sets.
    """
    if len(sets) == 0:
        return set()
    # Since 2.6 set.union accepts multiple input iterables.
    if sys.version_info >= (2, 6):
        return set.union(*sets)
    else:

        return reduce(operator.or_, sets, set())