[Tutor] A question about input/raw_input
Andrei Kulakov
ak@silmarill.org
Fri, 19 Apr 2002 14:43:58 -0400
On Fri, Apr 19, 2002 at 09:57:58AM +0100, Crane, Adam wrote:
> Ahh, I see. Thanks for clearing that up. I didn't know input was so
> useful.
>
It's dangerous, too. If user makes a mistake he may delete data, or
crash the program. If you use raw_input you can check that entered data
is "valid". You can say "give me a yes or no" and then check that input
was indeed either yes or no, and if not, print error and ask again.
I think input() and raw_input() are not well named. raw_input would
be best called input() or getline(), and input should be hidden
somewhere deep in libraries, like maybe os.unprocessed_input(). It's
a fairly common thing for new users to get confused by these two
functions.
If you plan to distribute your program to users, use raw_input. In fact,
you can't go wrong by using it everywhere.
- Andrei
[snip]
--
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: cy.silmarill.org