buggy python interpretter or am I missing something here?

Steven D'Aprano steve+comp.lang.python at pearwood.info
Mon Jan 27 17:25:43 EST 2014


On Mon, 27 Jan 2014 12:22:22 -0800, Rick Johnson wrote:

> "input" is only used by neophytes, so who cares about breaking that one,
> but "print" is almost everywhere!

Heh heh heh, how very "Ranting Rick" to think that a function for 
listening to input is unimportant, while a function for spraying output 
all over the place is vital.


> But let's go back to "input" for a bit...
> 
> Why do we even need an "input" function anyway if all it is going to do
> is read from stdin? 

That's not all it does.

For example, it handles backspacing, so that typing H E L O O BACKSPACE 
BACKSPACE L O gives "HELLO" rather than "HELOO\x7f\x7fO".

Of course, somebody as awesome as Rick will have never made a mistake in 
his life, but for the rest of us mere mortals, that feature alone makes a 
dedicated input function worthwhile. But there's more!

On systems with readline, not only does input handle backspacing, but it 
handles all sorts of editing functionality, such as arrow keys and 
various editing commands. So typing A LEFT-ARROW B gives "BA" rather than 
"A\x1b[DB". input also provides visual feedback while you type, an 
optional prompt, handling of newlines, buffering, and possibly more.


-- 
Steven



More information about the Python-list mailing list