@pipe.func<EOL>def pack(prev, n, rest=False, **kw):
if '<STR_LIT>' in kw:<EOL><INDENT>use_padding = True<EOL>padding = kw['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>use_padding = False<EOL>padding = None<EOL><DEDENT>items = []<EOL>for i, data in enumerate(prev, <NUM_LIT:1>):<EOL><INDENT>items.append(data)<EOL>if (i % n) == <NUM_LIT:0>:<EOL><INDENT>yield items<EOL>items = []<EOL><DEDENT><DEDENT>if len(items) != <NUM_LIT:0> and rest:<EOL><INDENT>if use_padding:<EOL><INDENT>items.extend([padding, ] * (n - (i % n)))<EOL><DEDENT>yield items<EOL><DEDENT>
pack pipe takes n elements from previous generator and yield one
    list to next.

    :param prev: The previous iterator of pipe.
    :type prev: Pipe
    :param rest: Set True to allow to output the rest part of last elements.
    :type prev: boolean
    :param padding: Specify the padding element for the rest part of last elements.
    :type prev: boolean
    :returns: generator

    :Example:
    >>> result([1,2,3,4,5,6,7] | pack(3))
    [[1, 2, 3], [4, 5, 6]]

    >>> result([1,2,3,4,5,6,7] | pack(3, rest=True))
    [[1, 2, 3], [4, 5, 6], [7,]]

    >>> result([1,2,3,4,5,6,7] | pack(3, padding=None))
    [[1, 2, 3], [4, 5, 6], [7, None, None]]