[Python-ideas] List Comprehensions
Steve Dower
steve.dower at python.org
Fri Feb 5 00:21:11 EST 2016
In Python 3.5:
>>> [*(x for x in range(10)), 100]
Should give [0, 1 ... 10, 100]. You can now expand sequence and dict items with * and **, similar to how function calls work.
Top-posted from my Windows Phone
-----Original Message-----
From: "shiva prasanth" <kesavarapu.siva at gmail.com>
Sent: 2/3/2016 1:00
To: "python-ideas at python.org" <python-ideas at python.org>
Subject: [Python-ideas] List Comprehensions
python input and output
In [2]: z=[ x for x in range(10)]
In [3]: z
Out[3]: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
In [4]: z=[x for x in range(10),100] # should be [ 0 , 1, 2, 3, 4, 5, 6, 7, 8, 9, 100]
# but output is not as expected
# following is the output
# other wise it should show error
In [5]: z
Out[5]: [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 100]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160204/8a6c62a4/attachment-0001.html>
More information about the Python-ideas
mailing list