[docs] bug report for itertools.takewhile

reloaded emacsnt at foxmail.com
Wed Jan 24 02:19:29 EST 2018


hi, python officer


I am not sure whether it is a correct behavior for takewhile function


from itertools import takewhile
print(list(takewhile(lambda x:x%2==0, [2,1])))
print(list(takewhile(lambda x:x%2==0, [1,2])))
this codes results
[2]
[]


it seems that all the elements after 1 (in the second argument ) will be ignored(or discarded) by takewhile function
print(list(takewhile(lambda x:x%2==0, [2,1,4,6,8])))
[2]
print(list(takewhile(lambda x:x%2==0, [1,2,4,6,8])))
[]


it appeared on python3.5.2(win64) and python 3.6.4(CentOS7.1). I do not test on other version of python


your sincerely
Jacky
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/docs/attachments/20180124/82b5cb3c/attachment.html>


More information about the docs mailing list