Message291772
> 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. |
|
Date |
User |
Action |
Args |
2017-04-17 01:12:49 | steven.daprano | set | recipients:
+ steven.daprano, ezio.melotti, mrabarnett, umedoblock, martin.panter |
2017-04-17 01:12:49 | steven.daprano | set | messageid: <1492391569.4.0.422129051388.issue30084@psf.upfronthosting.co.za> |
2017-04-17 01:12:49 | steven.daprano | link | issue30084 messages |
2017-04-17 01:12:48 | steven.daprano | create | |
|