Questions: While And List Comprehension

alex23 wuwei23 at gmail.com
Wed Nov 10 20:01:52 EST 2010


Steve Holden <st... at holdenweb.com> wrote:
> how about print [sys.stdin.readline() for i in range(5)]
>
> At least that won't consume the whole file.

+1 on this approach. Clear and obvious and not reliant on any library
modules other than sys.

itertools, what WAS I thinking? :)



More information about the Python-list mailing list