[docs] bug report for itertools.takewhile 20180124

reloaded emacsnt at foxmail.com
Wed Jan 24 02:12:40 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 code results
[2]
[]


it seems that all the number 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])))

[]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/docs/attachments/20180124/0e3c7a86/attachment-0001.html>


More information about the docs mailing list