Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 3
0
def test_ensure_iterable():
    el = 1
    new_el = ensure_iterable(el)
    assert new_el == [el]
Exemplo n.º 4
0
def test_ensure_iterable_string():
    el = 'test'
    new_el = ensure_iterable(el)
    assert new_el == [el]
Exemplo n.º 5
0
def test_ensure_iterable_string():
    el = 'test'
    new_el = ensure_iterable(el)
    assert new_el == [el]