On Sat, Mar 15, 2008 at 2:05 PM, BJörn Lindqvist <[EMAIL PROTECTED]> wrote:

> On Sat, Mar 15, 2008 at 4:15 PM, Guido van Rossum <[EMAIL PROTECTED]>
> wrote:
> >  >>> 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]
>
> Can you mix freely?
>
> >>> [*(*item, *item) for item in L]
> [0, 1, 2, 0, 1, 2, 3, 4, 3, 4, 5, 5, 6, 6, 7, 8, 9, 7, 8, 9]
>

Of course. It's just a generalization of *, it's not a special case.
[*(*item, *item)] is automatically parsed correctly. Of course, since L
contains a generator, the output isn't entirely like you suggested:

 >>> a = [0, 1, 2]
>>> L = [ a, (3, 4), {5}, {6: None}, (i for i in range(7, 10)) ]
>>> [*(*item, *item) for item in L]
[0, 1, 2, 0, 1, 2, 3, 4, 3, 4, 5, 5, 6, 6, 7, 8, 9]

The only thing that doesn't work (yet) is:

list(*item for item in L)

because the grammar gets confused about the '*item'. This is caused by the
specialcasing that *args and **kwargs in functioncalls and -definitions
really is. Since Guido wants to be able to do 'f(*a, b, c)' (and presumably
'f(*a, *b, *c)' too) that will all have to change anyway. However, changing
this part of the grammar is, uhm, "not as easy", so I need a couple of days.

-- 
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

Reply via email to