On Sun, Apr 03, 2005 at 09:49:42PM -0600, Steven Bethard wrote:
Slick. Thanks!
does isatty() actually work on windows? I'm a tiny bit surprised!
Jeff
pgp2TeZpqhdyV.pgp
Description: PGP signature
--
http://mail.python.org/mailman/listinfo/python-list
Jeff Epler wrote:
On Sun, Apr 03, 2005 at 09:49:42PM -0600, Steven Bethard wrote:
Slick. Thanks!
does isatty() actually work on windows? I'm a tiny bit surprised!
Hmm... I was just talking about using iter(f.readline, ''), but it does
appear that isatty returns True for sys.stdin in the
Jeff Epler wrote:
The iterator for files is a little bit like this generator function:
SNIP
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
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.
I'm not a Python expert by any means, but you're describing the
classic symptoms of buffering. There is a '-u' command line switch for
python to turn off buffering but that does not affect file iterators.
See http://www.hmug.org/man/1/python.html for instance.
Tom Eastman [EMAIL PROTECTED]
The iterator for files is a little bit like this generator function:
def lines(f):
while 1:
chunk = f.readlines(sizehint)
for line in chunk: yield line
Inside file.readlines, the read from the tty will block until sizehint
bytes have been read or EOF is seen.
Jeff Epler wrote:
The iterator for files is a little bit like this generator function:
def lines(f):
while 1:
chunk = f.readlines(sizehint)
for line in chunk: yield line
Inside file.readlines, the read from the tty will block until sizehint
bytes have been read