What if you had a list like this: [1, -10, [1,2,[3,4]], xrange(200)], and you just wanted to go through each element in order (wanted it to return a simple list of [1,-10,1,2,3,4,1,2,3,4...199])
I've seen a couple of attempts to flatten arbitrarily deep lists. Many of them involve recursion, like this one: http://rightfootin.blogspot.com/2006/09/more-on-python-flatten.html
Recursion is generally considered non-pythonic...
Oftentimes you want to find the index of a list-like object. Numpy arrays, for example, do not have a index member function. These get the job done quickly.
Note: these do not raise exceptions, instead they return -1 on error. You...
an object which extends the xrange object to support slicing and indexing (simple)
I have looked far and wide for code for fast sorting of n dimensional arrays by the first element, for example if I had the array: ray = [[1,2,3,7,5][10,11,12,13,14]]
I would want it to come out as ray =... |