Last active
December 27, 2020 18:26
-
-
Save wilfreddesert/9b902e3a2379459bdc3a60fbd16f80ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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