Skip to content

Proposal for new itertool postpend #780

@bjrtx

Description

@bjrtx

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']

Metadata

Metadata

Assignees

No one assigned

    Labels

    pr-welcomeWe are open to PRs that fix this issue - leave a note if you're working on it!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions