Remove comma from tuples in python.

Peter Otten __peter__ at web.de
Fri Feb 21 15:14:39 CET 2014


Tim Chase wrote:

> With the single-value tuple, I tend to find the parens make it more
> readable, so I'd go with
> 
> [x*x for (x,) in lst]
 
Hardly ever seen in the wild, but unpacking works with [...], too:

>>> items = zip(range(5))
>>> [x*x for [x] in items]
[0, 1, 4, 9, 16]





More information about the Python-list mailing list