예제 #1
0
def args_to_iterable(*args, **kwargs):
    """
    Convert arguments to iterables.


    Parameters
    ----------
    args: iterables or not
        arguments
    n : int, optional
        number of explicit arguments
    """
    if 'n' in kwargs:
        n = kwargs['n']
    else:
        n = len(args)

    arguments = []
    for i, arg in enumerate(args):
        arguments.append(ensure_iterable(arg))

    it = iter(arguments)
    for _ in range(n):
        yield next(it, None)
    if n < len(args):
        yield tuple(it)
예제 #2
0
def args_to_iterable(*args, **kwargs):
    """
    Convert arguments to iterables.


    Parameters
    ----------
    args: iterables or not
        arguments
    n : int, optional
        number of explicit arguments
    """
    if 'n' in kwargs:
        n = kwargs['n']
    else:
        n = len(args)

    arguments = []
    for i, arg in enumerate(args):
        arguments.append(ensure_iterable(arg))

    it = iter(arguments)
    for _ in range(n):
        yield next(it, None)
    if n < len(args):
        yield tuple(it)
예제 #3
0
def test_ensure_iterable():
    el = 1
    new_el = ensure_iterable(el)
    assert new_el == [el]
예제 #4
0
def test_ensure_iterable_string():
    el = 'test'
    new_el = ensure_iterable(el)
    assert new_el == [el]
예제 #5
0
def test_ensure_iterable_string():
    el = 'test'
    new_el = ensure_iterable(el)
    assert new_el == [el]