Closed
Description
Description
Would introduce
def postpend(iterator, value):
"""Yield the elements in *iterator* followed by value.
"""
return chain(iterator, [value])
append
is also a possible name, but clashes with list.append
.
References
- Natural counterpart to
prepend
, which already exists - Elementary operation on iterables, cf.
list.append
Examples
>>> value = '0'
>>> iterator = ['1', '2', '3']
>>> list(postpend(iterator, value))
[''1', '2', '3', '0']