On 02/01/2011 06:23 PM, Andre Engels wrote: > On Tue, Feb 1, 2011 at 9:40 PM, John Simon <[email protected]> wrote: >> I'm looking for a way to flatten lists inside a list literal, kind of like >> this: >> >>>>> start = '(' >>>>> end = ')' >>>>> items = ['abc', '+', 'def'] >>>>> [start, *items, end] >> ['(', 'abc', '+', 'def', ')'] >> Of course, the star doesn't work there. Is there any easy, >> syntactically-lightweight way to get that output? > > Is: > > [start] + items + [end] > > lightweight enough? >
That's what I was looking for. The simplest things sometimes go right over my head... Ignore my other post, but list comprehensions are a useful thing to know. _______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
