Popular recipes tagged "flatten" but not "tuple"http://code.activestate.com/recipes/tags/flatten-tuple/2014-10-05T21:44:45-07:00ActiveState Code RecipesFlattening an arbitrarily nested list in Python (Python) 2014-10-05T21:44:45-07:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/578948-flattening-an-arbitrarily-nested-list-in-python/ <p style="color: grey"> Python recipe 578948 by <a href="/recipes/users/4173351/">Vasudev Ram</a> (<a href="/recipes/tags/algorithm/">algorithm</a>, <a href="/recipes/tags/algorithms/">algorithms</a>, <a href="/recipes/tags/flatten/">flatten</a>, <a href="/recipes/tags/list/">list</a>, <a href="/recipes/tags/lists/">lists</a>, <a href="/recipes/tags/python/">python</a>). </p> <p>This is a recipe to flatten a Python list which may have nested lists as items within it. It works for lists that have a maximum depth of nesting roughly equal to the recursion depth limit of Python, which is set to 1000 by default, though it can be increased with sys.setrecursionlimit().</p> Python - from nD array to flat array (Python) 2014-03-21T16:09:39-07:00Roberto Bellohttp://code.activestate.com/recipes/users/4189498/http://code.activestate.com/recipes/578854-python-from-nd-array-to-flat-array/ <p style="color: grey"> Python recipe 578854 by <a href="/recipes/users/4189498/">Roberto Bello</a> (<a href="/recipes/tags/array/">array</a>, <a href="/recipes/tags/flatten/">flatten</a>, <a href="/recipes/tags/nd/">nd</a>). </p> <p>From a multidimensional array to a flat array avoiding numpy. The code could be better?</p> Flatten XML to XPath syntax lines (Python) 2011-01-19T16:05:24-08:00Raphaël Jolivethttp://code.activestate.com/recipes/users/4135673/http://code.activestate.com/recipes/577547-flatten-xml-to-xpath-syntax-lines/ <p style="color: grey"> Python recipe 577547 by <a href="/recipes/users/4135673/">Raphaël Jolivet</a> (<a href="/recipes/tags/flatten/">flatten</a>, <a href="/recipes/tags/grep/">grep</a>, <a href="/recipes/tags/sed/">sed</a>, <a href="/recipes/tags/xml/">xml</a>, <a href="/recipes/tags/xpath/">xpath</a>). </p> <p>This script acts like <a href="http://www.ofb.net/~egnor/xml2/">xml2</a>. It transforms a XML file into a flat text output, with <em>XPath</em>-like syntax, one line per XML node or attribute. This format is more suitable for working with standard unix CLI utils (sed, grep, ... etc).</p> Flattening lists (Python) 2010-12-21T16:04:38-08:00Michael Pucketthttp://code.activestate.com/recipes/users/4176295/http://code.activestate.com/recipes/577509-flattening-lists/ <p style="color: grey"> Python recipe 577509 by <a href="/recipes/users/4176295/">Michael Puckett</a> (<a href="/recipes/tags/flatten/">flatten</a>, <a href="/recipes/tags/list/">list</a>). </p> <p>Classic / frequently asked, <em>'How to flatten a list, regardless the nesting.'</em></p> Flatten a list (or list of lists, etc.) (Python) 2011-03-01T03:46:26-08:00Sunjay Varmahttp://code.activestate.com/recipes/users/4174115/http://code.activestate.com/recipes/577255-flatten-a-list-or-list-of-lists-etc/ <p style="color: grey"> Python recipe 577255 by <a href="/recipes/users/4174115/">Sunjay Varma</a> (<a href="/recipes/tags/extend/">extend</a>, <a href="/recipes/tags/flatten/">flatten</a>, <a href="/recipes/tags/list/">list</a>, <a href="/recipes/tags/optimization/">optimization</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/smart/">smart</a>). Revision 2. </p> <p>I created this function sometime ago for my own purposes. It simply flattens a list.</p> <p>Check out the first comment for another version of someone else's design.</p> Flatten a list (Python) 2010-06-18T03:45:20-07:00Giannis Fysakishttp://code.activestate.com/recipes/users/4174072/http://code.activestate.com/recipes/577250-flatten-a-list/ <p style="color: grey"> Python recipe 577250 by <a href="/recipes/users/4174072/">Giannis Fysakis</a> (<a href="/recipes/tags/flatten/">flatten</a>, <a href="/recipes/tags/list/">list</a>). Revision 3. </p> <p>Flatten a list </p> flatten sequences (Python) 2008-09-05T08:41:49-07:00Christophe Simonishttp://code.activestate.com/recipes/users/4166953/http://code.activestate.com/recipes/576487-flatten-sequences/ <p style="color: grey"> Python recipe 576487 by <a href="/recipes/users/4166953/">Christophe Simonis</a> (<a href="/recipes/tags/flatten/">flatten</a>, <a href="/recipes/tags/list/">list</a>). Revision 3. </p> <p>A simple method to flatten a sequence (list, tuple...)</p>