reading from sys.stdin

7stud bbxx789_05ss at yahoo.com
Thu Apr 12 04:20:58 EDT 2007


I can't break out of the for loop in this example:

------
import sys

lst = []
for line in sys.stdin:
    lst.append(line)
    break

print lst
-----------

But, I can break out of the for loop when I do this:

---------
import sys

lst = []
for line in open("aaa.txt"):
    lst.append(line)
    break

print lst
----------

Why doesn't break work in the first example?




More information about the Python-list mailing list