resolving map function issue in python 3 vs python 2 -
i'm interested in functional programming python , working through mary rose cook's blog post a practical introduction functional programming.
apparently, written in python 2 this:
name_lengths = map(len, ["mary", "isla", "sam"]) print name_lengths # => [4, 4, 3]
in python 3 yields this:
<map object @ 0x100b87a20>
i have 2 questions:
- why so?
- other converting map object list , use numpy, there other solutions?
as documented, in migration guide,
in python 2 map() returns list while in python 3 returns iterator.
apply function every item of iterable , return list of results.
return iterator applies function every item of iterable, yielding results.
python 2 equivalent of list(imap(...))
, python 3 allows lazy evaluation.
Comments
Post a Comment