3 ms·
Those aren't the same in Python 3. $ python3 >>> [2 * x for x in [1, 2, 3]] [2, 4, 6] >>> map(lambda x: 2 * x, [1, 2, 3]) <map object at 0x
by burntsushi 12y ago
Those aren't the same in Python 3.
$ python3
>>> [2 * x for x in [1, 2, 3]]
[2, 4, 6]
>>> map(lambda x: 2 * x, [1, 2, 3])
<map object at 0x7f160f535438>
- netheril96 12y agoThen use a generator expression: `(2 * x for x in [1, 2, 3])` This is functionally (pun intended) equivalent to `map(lambda x: 2 * x, [1, 2, 3])`