Wednesday, February 27, 2013

Using map() in Python 3


A: python 2.6:
>>> map(chr,[66,53,0,94])
['B', '5', '\x00', '^']
However, on 3.1, the above returns a map object.
B: python 3.1:
>>> map(chr,[66,53,0,94])
<map object at 0x00AF5570>
To return a list in Python 3 the following should be used:


list(map(chr,[66,53,0,94]))

0 коммент.:

Post a Comment

Powered by Blogger.