# Path: rash/utils/py3compat.py
# PY3 = (sys.version_info[0] >= 3)
#     def nested(*managers):


import itertools
from .py3compat import zip
            if len(queue) > num:
                queue.pop(0)
                yield False
    for _ in queue:
        yield False


def _forward_shifted_predicate(predicate, num, iterative, include_zero=True):
    counter = 0
    for elem in iterative:
        if predicate(elem):
            counter = num
            yield include_zero
        elif counter > 0:
            yield True
            counter -= 1
        else:
            yield False


def include_before(predicate, num, iterative):
    """
    Return elements in `iterative` including `num`-before elements.

    >>> list(include_before(lambda x: x == 'd', 2, 'abcded'))
    ['b', 'c', 'd', 'e', 'd']

    """
    (it0, it1) = itertools.tee(iterative)
    ps = _backward_shifted_predicate(predicate, num, it1)

# Path: rash/utils/py3compat.py
# PY3 = (sys.version_info[0] >= 3)
#     def nested(*managers):


# Path: rash/utils/iterutils.py
import itertools
from .py3compat import zip

            if len(queue) > num:
                queue.pop(0)
                yield False
    for _ in queue:
        yield False


def _forward_shifted_predicate(predicate, num, iterative, include_zero=True):
    counter = 0
    for elem in iterative:
        if predicate(elem):
            counter = num
            yield include_zero
        elif counter > 0:
            yield True
            counter -= 1
        else:
            yield False


def include_before(predicate, num, iterative):
    """
    Return elements in `iterative` including `num`-before elements.

    >>> list(include_before(lambda x: x == 'd', 2, 'abcded'))
    ['b', 'c', 'd', 'e', 'd']

    """
    (it0, it1) = itertools.tee(iterative)
    ps = _backward_shifted_predicate(predicate, num, it1)

    return (e for (e, p) in zip(it0, ps) if p)