Skip to content

Instantly share code, notes, and snippets.

@wilfreddesert
Last active December 27, 2020 18:26
Show Gist options
  • Save wilfreddesert/9b902e3a2379459bdc3a60fbd16f80ee to your computer and use it in GitHub Desktop.
Save wilfreddesert/9b902e3a2379459bdc3a60fbd16f80ee to your computer and use it in GitHub Desktop.
def chain(*args):
"""
>>> list(chain([[["test"]]]))
['t', 'e', 's', 't']
"""
for arg in args:
if isinstance(arg, str):
yield from arg
elif isinstance(arg, Iterable):
yield from chain(*arg)
else:
yield arg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment