(func, kwarg_name, list_or_value, **func_kwargs)
apply func(`kwarg_name`=elem, **`func_kwargs`) to every element
    of given `list_or_value` and return an iterator that flattens all results.

    `func` - a function that returns an iterable
    `kwarg_name` - a keyword argument to `func`
    `list_or_value` - a list of values to kwarg_name, or just a single value
    `func_kwargs` - any extra arguments to pass on
apply func(`kwarg_name`=elem, **`func_kwargs`) to every element
    of given `list_or_value` and return an iterator that flattens all results.
apply func ( kwarg_name = elem ** func_kwargs ) to every element of given list_or_value and return an iterator that flattens all results .
def flatmap_with_kwargs(func, kwarg_name, list_or_value, **func_kwargs):
    """apply func(`kwarg_name`=elem, **`func_kwargs`) to every element
    of given `list_or_value` and return an iterator that flattens all results.

    `func` - a function that returns an iterable
    `kwarg_name` - a keyword argument to `func`
    `list_or_value` - a list of values to kwarg_name, or just a single value
    `func_kwargs` - any extra arguments to pass on
    """
    if isinstance(list_or_value, collections.Sequence):
        for _grp in list_or_value:
            func_kwargs[kwarg_name] = _grp
            for rv in func(**func_kwargs):
                yield rv
    else:
        func_kwargs[kwarg_name] = list_or_value
        for rv in func(**func_kwargs):
            yield rv
def flatmap_with_kwargs ( func , kwarg_name , list_or_value , * * func_kwargs ) : if isinstance ( list_or_value , collections . Sequence ) : for _grp in list_or_value : func_kwargs [ kwarg_name ] = _grp for rv in func ( * * func_kwargs ) : yield rv else : func_kwargs [ kwarg_name ] = list_or_value for rv in func ( * * func_kwargs ) : yield rv