Pasting code into the cmdline interpreter

Gregory Ewing greg.ewing at canterbury.ac.nz
Fri Sep 23 02:24:01 EDT 2016


eryk sun wrote:
> if we see
> a read that returns less than the buffer size but doesn't end on a
> newline, then for a terminal, and only a terminal, I think we can
> infer Ctrl+D was typed and handle it as EOF.

I don't think it would be wise to rely on that. There is
no promise that any given read() call will read all the
data that's available.

Even if it worked, I'm not sure that this behaviour would
be desirable. Some programs may rely on the current
behaviour, e.g. shells that do auto-completion when you
type ctrl-D on a non-empty line.

At the very least it would make programs written in
Python behave differently from any other unix program
when reading from a terminal, which I don't think is
a good idea.

-- 
Greg




More information about the Python-list mailing list