Hi everyone,
I am trying to use the itertools module following the Python documentation, but I got some questions about it.
chain('ABC', 'DEF') --> A B C D E F
imap(pow,(2,3,10), (5,2,3)) --> 32 9 1000
However, the results are not the same as shown in the website.
The version of Python I am running is 2.7.9, and my codes are:
>>> import itertools
>>> itertools.chain('ABC', 'DEF')
<itertools.chain object at 0x0000000002A4B390>
>>> a = itertools.chain('ABC', 'DEF')
>>> a
<itertools.chain object at 0x0000000002A4B2E8>
>>> print a
<itertools.chain object at 0x0000000002A4B2E8>
>>> itertools.imap(pow, (2,3,10),(5,2,3))
<itertools.imap object at 0x0000000002A4B198>
>>> b = itertools.imap(pow, (2,3,10), (5,2,3))
>>> b
<itertools.imap object at 0x0000000002A4B240>
>>> print b
<itertools.imap object at 0x0000000002A4B240>
>>>
I do not know why the outputs would not be able to print as 'A B C D E F' and 32 9 100.
Could someone help me to understand it?
Cheers,
Huan
.