Message27525
| Author |
yohell |
| Recipients |
| Date |
2006年02月16日.11:17:51 |
| SpamBayes Score |
| Marked as misclassified |
| Message-id |
| In-reply-to |
| Content |
Logged In: YES
user_id=1008220
Well spoken!
However I'm not sure I quite follow you here:
> The last sentence above (the parenthetical one) is false
> for Linux/Unix. Once you hit EOF on a tty, it will return
> EOF forever until it's closed and re-opened.
A quote from Donn Cave in a discussion on comp.lang.python:
"""
They were probably thinking of the way the UNIX tty
driver delivers an EOF on <ctrl>D, after which of
course you can continue to read data from the same tty.
"""
This is also true for the Linux tty (afaik), so under those
circumstances it may really make sense to continue reading
past EOF.
example:
-------------------------------------------------
#!/usr/bin/python
import sys
while True:
s = sys.stdin.read()
print s
-------------------------------------------------
Pressing Ctrl-D while providing input to sys.stdin via the
keyboard will cause sys.stdin.read() to return, and you will
still be able to keep reading from sys.stdin without closing
and reopening it explicitly.
But then again I might have missed something.
/Joel Hedlund |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2007年08月23日 14:37:54 | admin | link | issue1432343 messages |
| 2007年08月23日 14:37:54 | admin | create |
|