--001a11c34e8edbc7c404f6a94bbe Content-Type: text/plain; charset=ISO-8859-1 >>> x=["a","b",["c","d"],"e"] >>> y=x[2] >>> y ['c', 'd'] >>> x.insert(2,y[0]) >>> x ['a', 'b', 'c', ['c', 'd'], 'e'] >>> x.insert(3,y[1]) >>> x ['a', 'b', 'c', 'd', ['c', 'd'], 'e'] >>> del x[4] >>> x ['a', 'b', 'c', 'd', 'e'] >>> maybe there is a more smart way to do. --001a11c34e8edbc7c404f6a94bbe Content-Type: text/html; charset=ISO-8859-1 <div dir="ltr"><div>>>> x=["a","b",["c","d"],"e"]<br>>>> y=x[2]<br>>>> y<br>['c', 'd']<br>>>> x.insert(2,y[0])<br>>>> x<br> ['a', 'b', 'c', ['c', 'd'], 'e']<br>>>> x.insert(3,y[1])<br>>>> x<br>['a', 'b', 'c', 'd', ['c', 'd'], 'e']<br> >>> del x[4]<br>>>> x<br>['a', 'b', 'c', 'd', 'e']<br>>>><br></div>maybe there is a more smart way to do.<br></div> --001a11c34e8edbc7c404f6a94bbe--

0 |

4/10/2014 5:14:49 AM

I've been using compiler.ast.flatten, but I have comments indicating it will need be replaced if/when I move to Python 3. I don't pollute my code base with flatten, I just call my own version in my utility library that is currently redirecting to flatten. flatten works equally well with tuples as lists and I'm going to remain consistent with that. My version returns a tuple as well. My love affair with the immutable, hashable, and wonderfully named tuple is perhaps something that needs its own thread, or private room. On Wednesday, April 9, 2014 10:14:49 PM UTC-7, length power wrote: > >>> x=["a","b",["c","d"],"e"] > >>> y=x[2] > >>> y > ['c', 'd'] > >>> x.insert(2,y[0]) > >>> x > > ['a', 'b', 'c', ['c', 'd'], 'e'] > >>> x.insert(3,y[1]) > >>> x > ['a', 'b', 'c', 'd', ['c', 'd'], 'e'] > > >>> del x[4] > >>> x > ['a', 'b', 'c', 'd', 'e'] > >>> > maybe there is a more smart way to do.

0 |

4/10/2014 5:36:46 PM