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:

  1. why so?
  2. 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.

python 2:

apply function every item of iterable , return list of results.

python 3:

return iterator applies function every item of iterable, yielding results.

python 2 equivalent of list(imap(...)), python 3 allows lazy evaluation.


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -