Interactive scripts (back on topic for once) [was Re: The "loop and a half"]
Steve D'Aprano
steve+python at pearwood.info
Fri Oct 6 06:41:08 EDT 2017
On Fri, 6 Oct 2017 09:33 pm, Ben Bacarisse wrote:
> A general solution to the (rather odd) complaint about silent waiting
> should really check any input fileno to see if a prompt is needed. You
> could argue, though, that anyone who's re-arranged a program's input so
> that some non-zero input fileno is attached to a terminal won't need the
> prompt!
I'm afraid I don't quite know if I'm understanding you or not.
I think you mean to say I should look at sys.stdin.fileno(), and if it is 0,
then write a prompt, and if not, just read from stdin (possibly blocking,
waiting for input).
Is that right?
But aren't there circumstances where fileno 0 isn't attached to a terminal,
and writing a prompt would be inappropriate?
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
More information about the Python-list
mailing list