请转到http://iMath.cnblogs.com

■■■■■■■■■■本博客打算放弃,请转到http://iMath.cnblogs.com


`map(function, iterable, ...)`  just return an iterator that applies function to every item of iterable, the function running results are only generated on demand, or “lazily”,we’ll say that it gives a promise to produce the values when they are needed. 



is there an easy way to apply function to every item of iterable? and once the function running finished , it should  make an impact right away ,




and return the running result not just an iterator, 


return the call result  that applies function to every item of iterable instead of an iterator, 


currently I just use this `list(map(function, iterable, ...))` to implement this feature , found it a little tedious



just want to run function on every item of an iterable and return the running result not just an iterator

just want to run function on every item of an iterable and do not care about the running result



>>> map(str.upper,['a','d'])

<map object at 0x023E1250>

>>> for i in map(str.upper,['a','d']):

print(i)


A

D

>>>


评论

© 请转到http://iMath.cnblogs.com | Powered by LOFTER