TypeError with map with no len()

john polo jpolo at mail.usf.edu
Mon Sep 25 13:58:06 EDT 2017


On 9/25/2017 12:03 PM, Paul Moore wrote:
> You're using Python 3, and I suspect that you're working from
> instructions that assume Python 2. In Python 3, the result of map() is
> a generator, not a list (which is what Python 2's map returned). In
> order to get an actual list (which appears to be what you need for
> your plot call) you just need to call the list constructor:
>
> y1 = list(map(math.sin, math.pi*t))
>
> Although given that you're using numpy, it may be that there's a more
> idiomatic numpy way of doing this. I'm not a numpy expert though, so I
> can't help on that.
>
> Paul
Paul,
Thank you very much for the explanation.

best regards,
John



More information about the Python-list mailing list