Questions: While And List Comprehension

alex23 wuwei23 at
Thu Nov 11 02:01:52 CET 2010

Steve Holden <st... at> 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