Skip to content

Instantly share code, notes, and snippets.

@antimirov
Created May 3, 2019 09:56
Show Gist options
  • Select an option

  • Save antimirov/1bb5ea36e78692f04dbb33cf376ce2bc to your computer and use it in GitHub Desktop.

Select an option

Save antimirov/1bb5ea36e78692f04dbb33cf376ce2bc to your computer and use it in GitHub Desktop.
Flatten a python list of arbitrary nesting
def flatten(arr):
for i in arr:
if isinstance(i, list):
yield from flatten(i)
else:
yield i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment