def flatten(sequence):
    """
    A simple generator which flattens a sequence.

    Only one level is flattened.

    .. code-block:: python

        (1, (2, 3), 4) -> (1, 2, 3, 4)

    """
    for item in sequence:
        if hasattr(item, '__iter__') and not isinstance(item, str
            ) and not isinstance(item, bytes):
            for i in item:
                yield i
        else:
            yield item
