Skip to content

Instantly share code, notes, and snippets.

@rdpate
Created December 2, 2024 07:19
Show Gist options
  • Save rdpate/a26ead2efa9998d134e1178776351f3c to your computer and use it in GitHub Desktop.
Save rdpate/a26ead2efa9998d134e1178776351f3c to your computer and use it in GitHub Desktop.
def chain_sep_end(iterable, sep=None, end=None):
it = iter(iterable)
for x in it:
yield x
break
for x in it:
if sep is not None:
yield sep
yield x
if end is not None:
yield end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment