def flatten(nested, containers=(list, tuple)):
for item in nested:<EOL><INDENT>if hasattr(item, "<STR_LIT>") or isinstance(item, containers):<EOL><INDENT>for subitem in flatten(item):<EOL><INDENT>yield subitem<EOL><DEDENT><DEDENT>else:<EOL><INDENT>yield item<EOL><DEDENT><DEDENT>
Flatten a nested list by yielding its scalar items.