def args_loader(source, factory, how_many=1):
    """
    A loader that yields values from a flattened list by grouping values
    together and instantiating a factory.  This loader can be used to
    prepopulate a datasets from command line arguments.

    All ``None`` values returned by the factory are skipped.

    This is a short example where each two consecutive values are grouped
    together and used to create tuple instances from a factory function:

    >>> from importtools import args_loader
    >>> args = ['A1', 'A2', 'B1', 'B2', 'C1', 'C2']
    >>> factory = lambda x, y: tuple([x, y])
    >>> al = args_loader(args, factory, 2)
    >>> sorted(al)
    [('A1', 'A2'), ('B1', 'B2'), ('C1', 'C2')]

    """
    assert len(source) % how_many == 0
    arg_groups = zip(*([iter(source)] * how_many))
    for arg_group in arg_groups:
        value = factory(*arg_group)
        if value is not None:
            yield value
