4 ms·
> Except the former resolves to an actual list value, whereas the latter is a generator. The latter is an actual list value if you're still using Python 2:
by Sohcahtoa82 8y ago
> Except the former resolves to an actual list value, whereas the latter is a generator.
The latter is an actual list value if you're still using Python 2:
pi@raspberrypi ~ $ python
Python 2.7.3 (default, Nov 24 2017, 21:13:24)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> map(lambda x: x^2, filter(lambda x: x < 10, [1,2,3]))
[3, 0, 1]
>>>
pi@raspberrypi ~ $ python3
Python 3.2.3 (default, Mar 25 2017, 13:24:50)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> map(lambda x: x^2, filter(lambda x: x < 10, [1,2,3]))
<map object at 0x76a72570>
- DonaldPShimoda 8y agoRight, you're quite correct! I assumed OP was using Python 3 since that's the current version, and their statement would have been true in 3 with the small change I suggested. Their point is still correct overall, but if they're going to make an example from an older version of the language I think they ought to specify as much.
- garmaine 8y agoPython 3 is a different language :)