<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def extract(values, types, skip=False):
 """Return a generator that extracts certain objects from `values`. This function is thought for supporting the definition of functions with arguments, that can be objects of of contain types or that can be iterables containing these objects. The following examples show that function |extract| basically implements a type specific flattening mechanism: ('str1',) ('str1', 'str2') ('str1', 'str2', 1) If an object is neither iterable nor of the required type, the following exception is raised: Traceback (most recent call last):
 TypeError: The given value `None` is neither iterable nor \ an instance of the following classes: str and int. Optionally, |None| values can be skipped: () ('str1', 'str2', 1) """

    if isinstance(values, types):
        yield values
    elif skip and (values is None):
        return
    else:
        try:
            for value in values:
                for subvalue in extract(value, types, skip):
                    yield subvalue
        except TypeError as exc:
            if exc.args[0].startswith('The given value'):
                raise exc
            else:
                raise TypeError(
                    f'The given value `{repr(values)}` is neither iterable '
                    f'nor an instance of the following classes: '
                    f'{enumeration(types, converter=instancename)}.')