The following simple code returns an error, even with list():
map(max,[1,2,3,4])
Out[123]: <map at 0xdff50f0320>
list(map(max,[1,2,3,4]))
TypeError: 'int' object is not iterable
I used list to map object is to display the content; it seems not work this way. How to see the map object?
map(max, [1,2,3,4])callsmax(1), thenmax(2), thenmax(3), thenmax(4). None of those calls make any sense. What did you want it to call? Justmax([1,2,3,4])withoutmap? Or something different?map(max, [1,2,3,4])without thelist(…)is that you're just creating the map iterator. It doesn't try to callmap(1)(which raises the exception) until you try to use the iterator.