Pasting code into the cmdline interpreter

Gregory Ewing greg.ewing at canterbury.ac.nz
Thu Sep 22 08:40:07 EDT 2016


eryk sun wrote:
> Actually in a Unix terminal the cursor can also be at
> the end of a line, but a bug in Python requires pressing Ctrl+D twice
> in that case.

I wouldn't call that a bug, rather it's a consequence of
what Ctrl-D does. It doesn't really mean EOF, it means to
send whatever the terminal driver has in its input buffer.
If the buffer is empty at the time, the process gets a
zero-length read which is taken as EOF. But if the buffer
is not empty, it just gets whatever is in the buffer.

There's nothing Python can do about that, because it
never sees the Ctrl-D -- that's handled entirely by the
terminal driver.

-- 
Greg



More information about the Python-list mailing list