Re: Silly question re: 'for i in sys.stdin'?

2005-04-04 Thread Tom Eastman
Jeff Epler wrote: > The iterator for files is a little bit like this generator function: > Cool thanks for that, it looks like iter(f.readline, '') is the best solution for the job. Tom -- http://mail.python.org/mailman/listinfo/python-list

Silly question re: 'for i in sys.stdin'?

2005-04-03 Thread Tom Eastman
I'm not new to Python, but I didn't realise that sys.stdin could be called as an iterator, very cool! However, when I use the following idiom: for line in sys.stdin: doSomethingWith(line) and then type stuff into the program interactively, nothing actually happens until I hit CTRL-D.