On Sat, Mar 15, 2008 at 9:15 AM, Guido van Rossum <[EMAIL PROTECTED]> wrote:
> Thomas Wouters suggests some new syntax: > > http://bugs.python.org/issue2292 > > >>> a, b, *c = range(5) > > >>> *a, b, c = a, b, *c > >>> a, b, c > ([0, 1, 2], 3, 4) > >>> [ *a, b, c ] > [0, 1, 2, 3, 4] > >>> L = [ a, (3, 4), {5}, {6: None}, (i for i in range(7, 10)) ] > >>> [ *item for item in L ] > [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] > > Also, yielding everything from an iterator: > > >>> def flatten(iterables): > ... for it in iterables: > ... yield *it > ... > >>> L = [ a, (3, 4), {5}, {6: None}, (i for i in range(7, 10)) ] > >>> flatten(L) > [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] > As you mentioned in the ticket, that's actually a cut-and-paste error: >>> flatten(L) <generator object at 0xb7cc5fb4> >>> list(flatten(L)) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] Also, it does sets and setcomps too: >>> { *a, 0, 4} {0, 1, 2, 4} >>> L = [ a, (3, 4), {5}, {6: None}, (i for i in range(7, 10)) ] >>> { *item for item in L } {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} -- Thomas Wouters <[EMAIL PROTECTED]> Hi! I'm a .signature virus! copy me into your .signature file to help me spread!
_______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com