Since there is some behavior difference in map
(especially with three arguments between Python 2 and Python - Python 2 vs Python 3 - Difference in map behavior with three arguments?), I was trying to be "safe" by using from past.builtins import map
so that my functionality is intact. But it doesn't seem to be so?
Here is a Python 2 code:
map(lambda x: [x], [1, 2])
which gives:
[[1], [2]]
Here is the Python 3 code which I am expecting to behave the same way, but does not:
from past.builtins import map
map(lambda x: [x], [1, 2])
gives:
[1, 2]
Surprisingly the new map
works as expected:
from builtins import map # Not needed if you didn't evaluate the above code.
list(map(lambda x: [x], [1, 2]))
Is there a reason why past.builtins
's map
behaves like this? Is this a bug?
Looks like there are some problems in getting the Python 2 map
behavior using past.builtins
module as mentioned in the source code comments.