Top-rated recipes tagged "nonrecursive"http://code.activestate.com/recipes/tags/nonrecursive/top/2010-09-10T00:10:47-07:00ActiveState Code RecipesNon-recursive Flatten, leaves Strings and Dicts alone, minimal type assumptions, with tests (Python) 2010-09-10T00:10:47-07:00Manuel Garciahttp://code.activestate.com/recipes/users/2827266/http://code.activestate.com/recipes/577387-non-recursive-flatten-leaves-strings-and-dicts-alo/ <p style="color: grey"> Python recipe 577387 by <a href="/recipes/users/2827266/">Manuel Garcia</a> (<a href="/recipes/tags/nonrecursive/">nonrecursive</a>). </p> <p>I have written Flatten a few dozen times, and also searched the interwebs - I don't feel good about a heavily recursive function for Python, and some of the "type-sniffing" I saw in some codes seemed fishy - so I coded up this version. At least this increases the options. Handles strings, dictionaries, generators, sequences, lists, tuples -- in sensible ways. Handles arbitrarily deep levels of nesting. Does the bare minimum of type-sniffing. With Doctest tests.</p>