question about input() and/or raw_input()

Chris Angelico rosuav at gmail.com
Sat Jan 18 21:46:27 EST 2014


On Sun, Jan 19, 2014 at 8:33 AM, Terry Reedy <tjreedy at udel.edu> wrote:
> On 1/18/2014 1:30 PM, Roy Smith wrote:
>>
>> Pardon me for being cynical, but in the entire history of the universe,
>> has anybody ever used input()/raw_input() for anything other than a
>> homework problem?
>
>
> Homework problems (and 'toy' programs, such as hangman), whether in a
> programming class or elsewhere, are one of the intended use cases of Python.
> How else would you get interactive input without the complexity of a gui?

With the network :) I've written plenty of programs whose sole
interaction is via sockets (telnet, HTTP, SMTP, whatever), or a
database, or somesuch.

But I've also written my share of interactive programs that use the
console. Plenty of programs don't need the fanciness of a GUI, but
need to prompt the user for stuff. If I write something for my brother
(and only him), I'm inclined to spend less effort on the UI than I
would for something of wide distribution, and console I/O is
approximately zero effort.

BTW, I'm assuming your mention of "input()/raw_input()" is covering
Py3 and Py2, respectively. I have *never* used input() in live Py2
code, and never intend to. It's way too subtle. On those really rare
occasions when you actually want to take something from the user and
immediately eval it, the extra keystrokes for eval(raw_input()) are,
IMO, a small price for the clarity.

ChrisA



More information about the Python-list mailing list