Steven D'Aprano added the comment:

> list expression pass starred expression, the other hand
> tuple expression cannot pass starred expression.

You are misinterpreting what you are seeing.

( ) is not a tuple expression (except for the special case of empty brackets, 
which makes an empty tuple). It's just grouping an expression. So (*x) is 
equivalent to just bare *x.

To make a tuple, you need a comma.

Apart from the empty tuple, the brackets are just for grouping. Put a comma 
after the starred expression and it will work:

py> t = 1, 2
py> t
(1, 2)
py> (*t,)
(1, 2)


The trailing comma is allowed in lists as well:

py> [*t,]
[1, 2]


I agree with Martin: there's no bug here, the behaviour is consistent with the 
way tuples and lists are normally created, and there's no need to make (*t) yet 
another special case.

If you really want to argue in favour of this change, I suggest you discuss it 
on the Python-Ideas mailing list and see if you can get community consensus for 
it. *If* you get agreement that this is a good idea, then you can re-open this.

----------
nosy: +steven.daprano
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue30084>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to